X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=kvlist.h;h=eaa691c229443843c1be417013a1ddfb2ccf90b0;hp=d59ff9e07227d58c4125e46b661e80c827b6b0c2;hb=4bc3decf8743c0add93d434a639bb1b449b6da11;hpb=1f019ceea1ed39286e6bccfb3ff936c22fe0f7c0 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)