string.h 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef NETDATA_STRING_H
  2. #define NETDATA_STRING_H 1
  3. #include "../libnetdata.h"
  4. // ----------------------------------------------------------------------------
  5. // STRING implementation
  6. typedef struct netdata_string STRING;
  7. STRING *string_strdupz(const char *str);
  8. STRING *string_dup(STRING *string);
  9. void string_freez(STRING *string);
  10. size_t string_strlen(STRING *string);
  11. const char *string2str(STRING *string) NEVERNULL;
  12. int string_strcmp(STRING *string, const char *s);
  13. // keep common prefix/suffix and replace everything else with [x]
  14. STRING *string_2way_merge(STRING *a, STRING *b);
  15. static inline int string_cmp(STRING *s1, STRING *s2) {
  16. // STRINGs are deduplicated, so the same strings have the same pointer
  17. // when they differ, we do the typical strcmp() comparison
  18. return (s1 == s2)?0:strcmp(string2str(s1), string2str(s2));
  19. }
  20. void string_statistics(size_t *inserts, size_t *deletes, size_t *searches, size_t *entries, size_t *references, size_t *memory, size_t *duplications, size_t *releases);
  21. int string_unittest(size_t entries);
  22. #endif