diff options
| author | David Lamparter <equinox@diac24.net> | 2019-05-21 05:16:08 +0200 |
|---|---|---|
| committer | David Lamparter <equinox@diac24.net> | 2019-05-21 05:42:13 +0200 |
| commit | 9680a2af1c24e8de4e576328d69cad1199ad56a6 (patch) | |
| tree | 3b33fa4b3496435313365ac1f26518fc687afe3a | |
| parent | 5cb4277dfe5d9cee195ad62fa43996ff8245ee72 (diff) | |
lib: add missing atomlist_init/fini
Only noticed this when trying to add atomlists to the typesafe
datastructure tests... the atomic-specific test_atomlist doesn't use
init/fini :/
Signed-off-by: David Lamparter <equinox@diac24.net>
| -rw-r--r-- | lib/atomlist.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/atomlist.h b/lib/atomlist.h index 373c481f2a..e4098ccb54 100644 --- a/lib/atomlist.h +++ b/lib/atomlist.h @@ -152,6 +152,15 @@ macro_inline type *prefix ## _next_safe(struct prefix##_head *h, type *item) \ { return item ? prefix##_next(h, item) : NULL; } \ macro_inline size_t prefix ## _count(struct prefix##_head *h) \ { return atomic_load_explicit(&h->ah.count, memory_order_relaxed); } \ +macro_inline void prefix ## _init(struct prefix##_head *h) \ +{ \ + memset(h, 0, sizeof(*h)); \ +} \ +macro_inline void prefix ## _fini(struct prefix##_head *h) \ +{ \ + assert(prefix ## _count(h) == 0); \ + memset(h, 0, sizeof(*h)); \ +} \ /* ... */ /* add_head: |
