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>2011-02-06 20:01:37 +0300
committerFelix Fietkau <nbd@openwrt.org>2011-02-06 20:01:37 +0300
commit677e7bc0b332a09fde6142119f42e5bac11979d3 (patch)
tree3c06bb0d6d31110b02ecebd10232ebc274a2d6d2 /avl.h
parentc9e852301ba4059da47418fcaede22d6fa4603e9 (diff)
make __avl_find_element() inline
Diffstat (limited to 'avl.h')
-rw-r--r--avl.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/avl.h b/avl.h
index 80a29b7..a563716 100644
--- a/avl.h
+++ b/avl.h
@@ -160,8 +160,6 @@ struct avl_node *EXPORT(avl_find_greaterequal)(const struct avl_tree *tree, cons
struct avl_node *EXPORT(avl_find_lessequal)(const struct avl_tree *tree, const void *key);
int EXPORT(avl_insert)(struct avl_tree *, struct avl_node *);
void EXPORT(avl_delete)(struct avl_tree *, struct avl_node *);
-void *EXPORT(__avl_find_element)(const struct avl_tree *tree, const void *key,
- size_t offset, enum avl_find_mode mode);
/**
* @param tree pointer to avl-tree
@@ -193,6 +191,32 @@ avl_is_empty(struct avl_tree *tree) {
}
/**
+ * Internal function to support returning the element from a avl tree query
+ * @param tree pointer to avl tree
+ * @param key pointer to key
+ * @param offset offset of node inside the embedded struct
+ * @param mode mode of lookup operation (less equal, equal or greater equal)
+ * @param pointer to elemen, NULL if no fitting one was found
+ */
+static inline void *
+__avl_find_element(const struct avl_tree *tree, const void *key, size_t offset, enum avl_find_mode mode) {
+ void *node = NULL;
+
+ switch (mode) {
+ case AVL_FIND_EQUAL:
+ node = avl_find(tree, key);
+ break;
+ case AVL_FIND_LESSEQUAL:
+ node = avl_find_lessequal(tree, key);
+ break;
+ case AVL_FIND_GREATEREQUAL:
+ node = avl_find_greaterequal(tree, key);
+ break;
+ }
+ return node == NULL ? NULL : (((char *)node) - offset);
+}
+
+/**
* @param tree pointer to avl-tree
* @param key pointer to key
* @param element pointer to a node element