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
path: root/avl.h
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-03-27 20:39:53 +0400
committerFelix Fietkau <nbd@openwrt.org>2014-03-27 20:39:53 +0400
commitf59f33f2c723b3c52f221234656d0e522a4dae00 (patch)
tree2794ced4ce318224822c09932761337bd47a3269 /avl.h
parent93b415c08d78ae5cb1bec077cd9e5ced9d4bb8a0 (diff)
avl: add AVL_TREE macro to define an initialized struct avl_tree
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'avl.h')
-rw-r--r--avl.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/avl.h b/avl.h
index e4ca7d8..c468597 100644
--- a/avl.h
+++ b/avl.h
@@ -153,6 +153,18 @@ enum avl_find_mode {
AVL_FIND_GREATEREQUAL
};
+#define AVL_TREE_INIT(_name, _comp, _allow_dups, _cmp_ptr) \
+ { \
+ .list_head = LIST_HEAD_INIT(_name.list_head), \
+ .comp = _comp, \
+ .allow_dups = _allow_dups, \
+ .cmp_ptr = _cmp_ptr \
+ }
+
+#define AVL_TREE(_name, _comp, _allow_dups, _cmp_ptr) \
+ struct avl_tree _name = \
+ AVL_TREE_INIT(_name, _comp, _allow_dups, _cmp_ptr)
+
void EXPORT(avl_init)(struct avl_tree *, avl_tree_comp, bool, void *);
struct avl_node *EXPORT(avl_find)(const struct avl_tree *, const void *);
struct avl_node *EXPORT(avl_find_greaterequal)(const struct avl_tree *tree, const void *key);