MINOR: dict: Add dictionary new data structure.
This patch adds minimalistic definitions to implement dictionary new data structure
which is an ebtree of ebpt_node structs with strings as keys. Note that this has nothing
to see with real dictionary data structure (maps of keys in association with values).
diff --git a/include/common/hathreads.h b/include/common/hathreads.h
index 0ba56d0..79a6466 100644
--- a/include/common/hathreads.h
+++ b/include/common/hathreads.h
@@ -547,6 +547,7 @@
TLSKEYS_REF_LOCK,
AUTH_LOCK,
LOGSRV_LOCK,
+ DICT_LOCK,
OTHER_LOCK,
LOCK_LABELS
};
@@ -663,6 +664,7 @@
case TLSKEYS_REF_LOCK: return "TLSKEYS_REF";
case AUTH_LOCK: return "AUTH";
case LOGSRV_LOCK: return "LOGSRV";
+ case DICT_LOCK: return "DICT";
case OTHER_LOCK: return "OTHER";
case LOCK_LABELS: break; /* keep compiler happy */
};
diff --git a/include/proto/dict.h b/include/proto/dict.h
new file mode 100644
index 0000000..26f48de
--- /dev/null
+++ b/include/proto/dict.h
@@ -0,0 +1,9 @@
+#ifndef _PROTO_DICT_H
+#define _PROTO_DICT_H
+
+#include <types/dict.h>
+
+struct dict *new_dict(const char *name);
+struct dict_entry *dict_insert(struct dict *d, char *str);
+
+#endif /* _PROTO_DICT_H */
diff --git a/include/types/dict.h b/include/types/dict.h
new file mode 100644
index 0000000..9e4f41a
--- /dev/null
+++ b/include/types/dict.h
@@ -0,0 +1,18 @@
+#ifndef _TYPES_DICT_H
+#define _TYPES_DICT_H
+
+#include <common/hathreads.h>
+#include <ebpttree.h>
+
+struct dict_entry {
+ struct ebpt_node value;
+ unsigned int refcount;
+};
+
+struct dict {
+ const char *name;
+ struct eb_root values;
+ __decl_hathreads(HA_RWLOCK_T rwlock);
+};
+
+#endif /* _TYPES_DICT_H */