string.h 1018 B

123456789101112131415161718192021222324252627282930
  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. // keep common prefix/suffix and replace everything else with [x]
  13. STRING *string_2way_merge(STRING *a, STRING *b);
  14. static inline int string_cmp(STRING *s1, STRING *s2) {
  15. // STRINGs are deduplicated, so the same strings have the same pointer
  16. // when they differ, we do the typical strcmp() comparison
  17. return (s1 == s2)?0:strcmp(string2str(s1), string2str(s2));
  18. }
  19. 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);
  20. int string_unittest(size_t entries);
  21. #endif