]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add missing atomlist_init/fini
authorDavid Lamparter <equinox@diac24.net>
Tue, 21 May 2019 03:16:08 +0000 (05:16 +0200)
committerDavid Lamparter <equinox@diac24.net>
Tue, 21 May 2019 03:42:13 +0000 (05:42 +0200)
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>
lib/atomlist.h

index 373c481f2a70834850b6992ee0803bb3fdcad0d8..e4098ccb54d12b2140e810efac7d7691142c4adb 100644 (file)
@@ -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: