diff --git a/include/jemalloc/internal/ql.h b/include/jemalloc/internal/ql.h index 3b780609..b1ce4793 100644 --- a/include/jemalloc/internal/ql.h +++ b/include/jemalloc/internal/ql.h @@ -18,6 +18,8 @@ struct { \ (a_head)->qlh_first = NULL; \ } while (0) +#define ql_empty(a_head) ((a_head)->qlh_first == NULL) + #define ql_elm_new(a_elm, a_field) qr_new((a_elm), a_field) #define ql_first(a_head) ((a_head)->qlh_first) diff --git a/test/unit/ql.c b/test/unit/ql.c index 662d1e8b..8f689389 100644 --- a/test/unit/ql.c +++ b/test/unit/ql.c @@ -18,6 +18,7 @@ test_empty_list(list_head_t *head) { list_t *t; unsigned i; + expect_true(ql_empty(head), "Unexpected element for empty list"); expect_ptr_null(ql_first(head), "Unexpected element for empty list"); expect_ptr_null(ql_last(head, link), "Unexpected element for empty list"); @@ -58,6 +59,7 @@ test_entries_list(list_head_t *head, list_t *entries, unsigned nentries) { list_t *t; unsigned i; + expect_false(ql_empty(head), "List should not be empty"); expect_c_eq(ql_first(head)->id, entries[0].id, "Element id mismatch"); expect_c_eq(ql_last(head, link)->id, entries[nentries-1].id, "Element id mismatch");