]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add ISC_{LIST,LINK}_INITIALIZER for designated initializers
authorOndřej Surý <ondrej@isc.org>
Tue, 18 Oct 2022 09:15:57 +0000 (11:15 +0200)
committerOndřej Surý <ondrej@isc.org>
Tue, 18 Oct 2022 09:36:15 +0000 (11:36 +0200)
Since we are using designated initializers, we were missing initializers
for ISC_LIST and ISC_LINK, add them, so you can do

    *foo = (foo_t){ .list = ISC_LIST_INITIALIZER };

Instead of:

    *foo = (foo_t){ 0 };
    ISC_LIST_INIT(foo->list);

lib/isc/include/isc/list.h

index b7a783c3adb16cc0bcb625a74bddfa56e01b5178..007cec0f30d6427b63d654e13a677e0ce01e9362 100644 (file)
 
 #include <isc/assertions.h>
 
+#define ISC_LIST_INITIALIZER                \
+       {                                   \
+               .head = NULL, .tail = NULL, \
+       }
+#define ISC_LINK_INITIALIZER_TYPE(type)                 \
+       {                                               \
+               .prev = (type *)-1, .next = (type *)-1, \
+       }
+#define ISC_LINK_INITIALIZER ISC_LINK_INITIALIZER_TYPE(void)
+
 #ifdef ISC_LIST_CHECKINIT
 #define ISC_LINK_INSIST(x) ISC_INSIST(x)
 #else /* ifdef ISC_LIST_CHECKINIT */