diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2019-01-25 10:49:37 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2019-01-25 10:49:37 +0100 |
| commit | 404ebe62622150e77e311777dff8617eb974e834 (patch) | |
| tree | cc7f73d3e435d5b3ee85e2bef833e8de1fb133e3 /shared/c-list/src | |
| parent | 227c401a10a930af6fd5f123aef345fcd130d6aa (diff) | |
| parent | 3626b425d1bc017fdc6f1ea0cfd329d1e1681641 (diff) | |
Merge remote-tracking branch 'salsa/upstream' into upstream
Diffstat (limited to 'shared/c-list/src')
| -rw-r--r-- | shared/c-list/src/c-list.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shared/c-list/src/c-list.h b/shared/c-list/src/c-list.h index ff434d8d..3d44e330 100644 --- a/shared/c-list/src/c-list.h +++ b/shared/c-list/src/c-list.h @@ -367,6 +367,25 @@ static inline CList *c_list_last(CList *list) { _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ /** + * c_list_flush() - flush all entries from a list + * @list: list to flush + * + * This unlinks all entries from the given list @list and reinitializes their + * link-nodes via C_LIST_INIT(). + * + * Note that the entries are not modified in any other way, nor is their memory + * released. This function just unlinks them and resets all the list nodes. It + * is particularly useful with temporary lists on the stack in combination with + * the GCC-extension __attribute__((__cleanup__(arg))). + */ +static inline void c_list_flush(CList *list) { + CList *iter, *safe; + + c_list_for_each_safe_unlink(iter, safe, list) + /* empty */ ; +} + +/** * c_list_length() - return number of linked entries, excluding the head * @list: list to operate on * |