libsepol/cil: Add cil_list_is_empty macro

Add a macro, called cil_list_is_empty, that returns true if the
list pointer or list head is NULL.

Signed-off-by: James Carter <jwcart2@gmail.com>
Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
This commit is contained in:
James Carter 2023-04-13 09:10:31 -04:00
parent 347254695f
commit 085e330062
1 changed files with 3 additions and 0 deletions

View File

@ -44,6 +44,9 @@ struct cil_list_item {
void *data; void *data;
}; };
#define cil_list_is_empty(list) \
((list) == NULL || (list)->head == NULL)
#define cil_list_for_each(item, list) \ #define cil_list_for_each(item, list) \
for (item = (list)->head; item != NULL; item = item->next) for (item = (list)->head; item != NULL; item = item->next)