registry_url.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_REGISTRY_URL_H
  3. #define NETDATA_REGISTRY_URL_H 1
  4. #include "registry_internals.h"
  5. // ----------------------------------------------------------------------------
  6. // URL structures
  7. // Save memory by de-duplicating URLs
  8. // so instead of storing URLs all over the place
  9. // we store them here and we keep pointers elsewhere
  10. struct registry_url {
  11. avl_t avl;
  12. uint32_t hash; // the index hash
  13. uint32_t links; // the number of links to this URL - when none is left, we free it
  14. uint16_t len; // the length of the URL in bytes
  15. char url[1]; // the URL - dynamically allocated to more size
  16. };
  17. typedef struct registry_url REGISTRY_URL;
  18. // REGISTRY_URL INDEX
  19. extern int registry_url_compare(void *a, void *b);
  20. extern REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) WARNUNUSED;
  21. extern REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) NEVERNULL WARNUNUSED;
  22. // REGISTRY_URL MANAGEMENT
  23. extern REGISTRY_URL *registry_url_get(const char *url, size_t urllen) NEVERNULL;
  24. extern void registry_url_link(REGISTRY_URL *u);
  25. extern void registry_url_unlink(REGISTRY_URL *u);
  26. #endif //NETDATA_REGISTRY_URL_H