Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2016-10-24 13:34:09 +0300
committerFelix Fietkau <nbd@nbd.name>2016-10-24 13:34:09 +0300
commitd0312bd9b1c81a8b428a32f29fba63279024fa76 (patch)
tree7781cab12722a84dcf3d9ebcece8394dfdf6f320 /kvlist.h
parent290c64ef5b5c3e75be851594f269d6a9568e64e5 (diff)
kvlist: add static initializer macros
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'kvlist.h')
-rw-r--r--kvlist.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/kvlist.h b/kvlist.h
index d59ff9e..eaa691c 100644
--- a/kvlist.h
+++ b/kvlist.h
@@ -18,6 +18,7 @@
#ifndef __LIBUBOX_KVLIST_H
#define __LIBUBOX_KVLIST_H
+#include "avl-cmp.h"
#include "avl.h"
struct kvlist {
@@ -32,6 +33,15 @@ struct kvlist_node {
char data[0] __attribute__((aligned(4)));
};
+#define KVLIST_INIT(_name, _get_len) \
+ { \
+ .avl = AVL_TREE_INIT(_name.avl, avl_strcmp, false, NULL), \
+ .get_len = _get_len \
+ }
+
+#define KVLIST(_name, _get_len) \
+ struct kvlist _name = KVLIST_INIT(_name, _get_len)
+
#define __ptr_to_kv(_ptr) container_of(((char *) (_ptr)), struct kvlist_node, data[0])
#define __avl_list_to_kv(_l) container_of(_l, struct kvlist_node, avl.list)