]> arthur.barton.de Git - netdata.git/blob - src/registry_url.h
Merge pull request #1998 from ktsaou/master
[netdata.git] / src / registry_url.h
1 #ifndef NETDATA_REGISTRY_URL_H
2 #define NETDATA_REGISTRY_URL_H
3
4 #include "registry_internals.h"
5
6 // ----------------------------------------------------------------------------
7 // URL structures
8 // Save memory by de-duplicating URLs
9 // so instead of storing URLs all over the place
10 // we store them here and we keep pointers elsewhere
11
12 struct registry_url {
13     avl avl;
14     uint32_t hash;  // the index hash
15
16     uint32_t links; // the number of links to this URL - when none is left, we free it
17
18     uint16_t len;   // the length of the URL in bytes
19     char url[1];    // the URL - dynamically allocated to more size
20 };
21 typedef struct registry_url REGISTRY_URL;
22
23 // REGISTRY_URL INDEX
24 extern int registry_url_compare(void *a, void *b);
25 extern REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) WARNUNUSED;
26 extern REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) NEVERNULL WARNUNUSED;
27
28 // REGISTRY_URL MANAGEMENT
29 extern REGISTRY_URL *registry_url_get(const char *url, size_t urllen) NEVERNULL;
30 extern void registry_url_link(REGISTRY_URL *u);
31 extern void registry_url_unlink(REGISTRY_URL *u);
32
33 #endif //NETDATA_REGISTRY_URL_H