diff --git a/src/common/lists.c b/src/common/lists.c index e629e9dcc24e5431a0ddd8a0a0fb82f4a7918fcf..47503f4cec85ef460ce29f33e51dab2ee37f020b 100644 --- a/src/common/lists.c +++ b/src/common/lists.c @@ -177,3 +177,20 @@ size_t list_size(const list *l) return count; } + +/** + * list_is_empty - Checks whether the list is empty + * @l: list + * + * This function returns 1 if list is empty, 0 otherwise. + */ +int list_is_empty(const list *l) +{ + node *n = 0; + WALK_LIST(n, *l) { + return 0; + } + + return 1; +} + diff --git a/src/common/lists.h b/src/common/lists.h index 392f75dd73943548eaa4fa6dc1d369db07701d17..82c5b4dd44f05ee73cc11f45bd73ed4748d6ce55 100644 --- a/src/common/lists.h +++ b/src/common/lists.h @@ -82,6 +82,7 @@ void init_list(list *); void insert_node(node *, node *); void list_dup(list *dst, list *src, size_t itemsz); size_t list_size(const list *); +int list_is_empty(const list *l); /*! * \brief List item for string lists.