From 9945737a8f0612b8980d9da3db3e6a4ab8a247f4 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 25 Oct 2019 09:27:56 +0000 Subject: Add bigkv --- src/include/skalibs/bigkv.h | 41 ++++++++++++++++++++++++++++++++++++++++ src/include/skalibs/datastruct.h | 1 + 2 files changed, 42 insertions(+) create mode 100644 src/include/skalibs/bigkv.h (limited to 'src/include') diff --git a/src/include/skalibs/bigkv.h b/src/include/skalibs/bigkv.h new file mode 100644 index 0000000..a5b06c2 --- /dev/null +++ b/src/include/skalibs/bigkv.h @@ -0,0 +1,41 @@ +/* ISC license. */ + +#ifndef SKALIBS_BIGKV_H +#define SKALIBS_BIGKV_H + +#include +#include + +#include +#include +#include + +typedef struct bigkv_node_s bigkv_node_t, *bigkv_node_t_ref ; +struct bigkv_node_s +{ + size_t k ; + size_t v ; +} ; +#define BIGKV_NODE_ZERO { .k = 0, .v = 0 } + +typedef struct bigkv_s bigkv_t, *bigkv_t_ref ; +struct bigkv_s +{ + stralloc storage ; + genalloc nodes ; /* bigkv_node_t */ + avltree map ; +} ; +#define BIGKV_ZERO { .storage = STRALLOC_ZERO, .nodes = GENALLOC_ZERO, .map = AVLTREE_ZERO } +extern bigkv_t const bigkv_zero ; + +#define BIGKV_OPTIONS_NODUP 0x00000001u + +#define bigkv_len(b) avltree_len(&(b)->map) + +extern int bigkv_init (bigkv_t *, char const *const *, char, char const *, char const *, uint32_t) ; +#define bigkv_init_argv(b, argv) bigkv_init(b, (argv), '=', "--", "--", 0) +#define bigkv_init_envp(b, envp) bigkv_init(b, (envp), '=', 0, 0, 0) +extern char const *bigkv_search (bigkv_t const *, char const *) ; +extern void bigkv_free (bigkv_t *) ; + +#endif diff --git a/src/include/skalibs/datastruct.h b/src/include/skalibs/datastruct.h index 7e2813e..0f6c0f7 100644 --- a/src/include/skalibs/datastruct.h +++ b/src/include/skalibs/datastruct.h @@ -9,5 +9,6 @@ #include #include #include +#include #endif -- cgit v1.2.3