Merge pull request #28832 from dtardon/list-clear

Add LIST_CLEAR() helper that empties the list
This commit is contained in:
Luca Boccassi
2023-08-17 16:27:43 +01:00
committed by GitHub
22 changed files with 72 additions and 114 deletions
+12
View File
@@ -192,6 +192,18 @@
_p; \
})
#define LIST_CLEAR(name, head, free_func) \
_LIST_CLEAR(name, head, free_func, UNIQ_T(elem, UNIQ))
/* Clear the list, destroing each element with free_func */
#define _LIST_CLEAR(name, head, free_func, elem) \
({ \
typeof(head) elem; \
while ((elem = LIST_POP(name, head))) \
free_func(elem); \
head; \
})
/* Now include "macro.h", because we want our definition of assert() which the macros above use. We include
* it down here instead of up top, since macro.h pulls in log.h which in turn needs our own definitions. */
#include "macro.h"