]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/typerb.h
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / lib / typerb.h
index ce8446f853a901c503e5c09105ba2277aa3f1202..2d7b0ba63791f1dd34942aa2e8578852e2c7d1fe 100644 (file)
@@ -38,29 +38,30 @@ struct typed_rb_root {
        size_t count;
 };
 
-struct typed_rb_entry *typed_rb_insert(struct typed_rb_root *,
+struct typed_rb_entry *typed_rb_insert(struct typed_rb_root *rbt,
                struct typed_rb_entry *rbe,
                int (*cmpfn)(
                        const struct typed_rb_entry *a,
                        const struct typed_rb_entry *b));
-void typed_rb_remove(struct typed_rb_root *, struct typed_rb_entry *rbe);
-struct typed_rb_entry *typed_rb_find(struct typed_rb_root *,
+struct typed_rb_entry *typed_rb_remove(struct typed_rb_root *rbt,
+                                      struct typed_rb_entry *rbe);
+struct typed_rb_entry *typed_rb_find(struct typed_rb_root *rbt,
                const struct typed_rb_entry *rbe,
                int (*cmpfn)(
                        const struct typed_rb_entry *a,
                        const struct typed_rb_entry *b));
-struct typed_rb_entry *typed_rb_find_gteq(struct typed_rb_root *,
+struct typed_rb_entry *typed_rb_find_gteq(struct typed_rb_root *rbt,
                const struct typed_rb_entry *rbe,
                int (*cmpfn)(
                        const struct typed_rb_entry *a,
                        const struct typed_rb_entry *b));
-struct typed_rb_entry *typed_rb_find_lt(struct typed_rb_root *,
+struct typed_rb_entry *typed_rb_find_lt(struct typed_rb_root *rbt,
                const struct typed_rb_entry *rbe,
                int (*cmpfn)(
                        const struct typed_rb_entry *a,
                        const struct typed_rb_entry *b));
-struct typed_rb_entry *typed_rb_min(struct typed_rb_root *);
-struct typed_rb_entry *typed_rb_next(struct typed_rb_entry *);
+struct typed_rb_entry *typed_rb_min(struct typed_rb_root *rbt);
+struct typed_rb_entry *typed_rb_next(struct typed_rb_entry *rbe);
 
 #define _PREDECL_RBTREE(prefix)                                                \
 struct prefix ## _head { struct typed_rb_root rr; };                           \
@@ -99,9 +100,11 @@ macro_inline type *prefix ## _find_lt(struct prefix##_head *h,                 \
        re = typed_rb_find_lt(&h->rr, &item->field.re, cmpfn_nuq);             \
        return container_of_null(re, type, field.re);                          \
 }                                                                              \
-macro_inline void prefix ## _del(struct prefix##_head *h, type *item)          \
+macro_inline type *prefix ## _del(struct prefix##_head *h, type *item)         \
 {                                                                              \
-       typed_rb_remove(&h->rr, &item->field.re);                              \
+       struct typed_rb_entry *re;                                             \
+       re = typed_rb_remove(&h->rr, &item->field.re);                         \
+       return container_of_null(re, type, field.re);                          \
 }                                                                              \
 macro_inline type *prefix ## _pop(struct prefix##_head *h)                     \
 {                                                                              \
@@ -130,7 +133,7 @@ macro_pure type *prefix ## _next_safe(struct prefix##_head *h, type *item)     \
        re = item ? typed_rb_next(&item->field.re) : NULL;                     \
        return container_of_null(re, type, field.re);                          \
 }                                                                              \
-macro_pure size_t prefix ## _count(struct prefix##_head *h)                    \
+macro_pure size_t prefix ## _count(const struct prefix##_head *h)              \
 {                                                                              \
        return h->rr.count;                                                    \
 }                                                                              \