aboutsummaryrefslogtreecommitdiff
path: root/src/core/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/list.h')
-rw-r--r--src/core/list.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/list.h b/src/core/list.h
index 204057a2..d3c703bb 100644
--- a/src/core/list.h
+++ b/src/core/list.h
@@ -29,6 +29,16 @@ extern void nni_list_init_offset(nni_list *list, size_t offset);
#define NNI_LIST_INIT(list, type, field) \
nni_list_init_offset(list, offsetof(type, field))
+// NNI_LIST_INITIALIZER is used to initialize structures at declaration time.
+// The list argument is the structure being initialized and the type and
+// offset determine where the node lives within each item.
+#define NNI_LIST_INITIALIZER(list, type, field) \
+ { \
+ .ll_head.ln_next = &(list).ll_head, \
+ .ll_head.ln_prev = &(list).ll_head, \
+ .ll_offset = offsetof(type, field) \
+ }
+
#define NNI_LIST_NODE_INIT(node) \
do { \
(node)->ln_prev = (node)->ln_next = 0; \