summaryrefslogtreecommitdiffstats
path: root/src/dictionary.h
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2016-05-25 10:36:24 +0000
committerLennart Weller <lhw@ring0.de>2016-05-25 10:36:24 +0000
commitb4f64f72a3e4bf590c60b0cbd6cd365aa1a58542 (patch)
treee6706c727a1fedb44da614453ad3e429a7403a9b /src/dictionary.h
parentImported Upstream version 1.1.0 (diff)
downloadnetdata-b4f64f72a3e4bf590c60b0cbd6cd365aa1a58542.tar.xz
netdata-b4f64f72a3e4bf590c60b0cbd6cd365aa1a58542.zip
Imported Upstream version 1.2.0upstream/1.2.0
Diffstat (limited to 'src/dictionary.h')
-rw-r--r--src/dictionary.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/dictionary.h b/src/dictionary.h
index 9822b23c2..575f28271 100644
--- a/src/dictionary.h
+++ b/src/dictionary.h
@@ -1,4 +1,7 @@
+#include <pthread.h>
+
#include "web_buffer.h"
+#include "avl.h"
#ifndef NETDATA_DICTIONARY_H
#define NETDATA_DICTIONARY_H 1
@@ -10,20 +13,33 @@ typedef struct name_value {
// we first compare hashes, and only if the hashes are equal we do string comparisons
char *name;
- char *value;
-
- struct name_value *next;
+ void *value;
} NAME_VALUE;
typedef struct dictionary {
- NAME_VALUE *values;
avl_tree values_index;
+
+ uint8_t flags;
+
+ unsigned long long inserts;
+ unsigned long long deletes;
+ unsigned long long searches;
+ unsigned long long entries;
+
pthread_rwlock_t rwlock;
} DICTIONARY;
-extern DICTIONARY *dictionary_create(void);
+#define DICTIONARY_FLAG_DEFAULT 0x00000000
+#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001
+#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002
+#define DICTIONARY_FLAG_NAME_LINK_DONT_CLONE 0x00000004
+
+extern DICTIONARY *dictionary_create(uint32_t flags);
extern void dictionary_destroy(DICTIONARY *dict);
extern void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t value_len);
extern void *dictionary_get(DICTIONARY *dict, const char *name);
+extern int dictionary_del(DICTIONARY *dict, const char *name);
+
+extern int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *data), void *data);
#endif /* NETDATA_DICTIONARY_H */