diff options
author | David Lamparter <equinox@diac24.net> | 2021-02-24 11:57:15 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2021-11-10 10:39:17 +0100 |
commit | 4894e9c12a8ee0165930900bc3c3391060108516 (patch) | |
tree | 0730ac40b162dcf5cf077cacec5cb6736352ef8c /lib/xref.h | |
parent | lib: add missing include in typerb.h (diff) | |
download | frr-4894e9c12a8ee0165930900bc3c3391060108516.tar.xz frr-4894e9c12a8ee0165930900bc3c3391060108516.zip |
lib: stuff xrefs into a tree for lookup
... so we can actually access by UID without searching the entire list.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/xref.h')
-rw-r--r-- | lib/xref.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/xref.h b/lib/xref.h index 6cff1a376..0e3f00f69 100644 --- a/lib/xref.h +++ b/lib/xref.h @@ -22,6 +22,7 @@ #include <limits.h> #include <errno.h> #include "compiler.h" +#include "typesafe.h" #ifdef __cplusplus extern "C" { @@ -63,6 +64,8 @@ struct xref { /* type-specific bits appended by embedding this struct */ }; +PREDECL_RBTREE_UNIQ(xrefdata_uid); + struct xrefdata { /* pointer back to the const part; this will be initialized at * program startup by xref_block_add(). (Creating structs with @@ -88,8 +91,18 @@ struct xrefdata { uint32_t hashu32[2]; /* -- 32 bytes (on 64bit) -- */ + struct xrefdata_uid_item xui; }; +static inline int xrefdata_uid_cmp(const struct xrefdata *a, + const struct xrefdata *b) +{ + return strcmp(a->uid, b->uid); +} + +DECLARE_RBTREE_UNIQ(xrefdata_uid, struct xrefdata, xui, xrefdata_uid_cmp); +extern struct xrefdata_uid_head xrefdata_uid; + /* linker "magic" is used to create an array of pointers to struct xref. * the result is a contiguous block of pointers, each pointing to an xref * somewhere in the code. The linker gives us start and end pointers, we |