summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/string/string.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 12:08:18 +0000
commit5da14042f70711ea5cf66e034699730335462f66 (patch)
tree0f6354ccac934ed87a2d555f45be4c831cf92f4a /src/libnetdata/string/string.h
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-5da14042f70711ea5cf66e034699730335462f66.tar.xz
netdata-5da14042f70711ea5cf66e034699730335462f66.zip
Merging upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/string/string.h')
-rw-r--r--src/libnetdata/string/string.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libnetdata/string/string.h b/src/libnetdata/string/string.h
new file mode 100644
index 000000000..f2ff9666c
--- /dev/null
+++ b/src/libnetdata/string/string.h
@@ -0,0 +1,37 @@
+
+#ifndef NETDATA_STRING_H
+#define NETDATA_STRING_H 1
+
+#include "../libnetdata.h"
+
+// ----------------------------------------------------------------------------
+// STRING implementation
+
+typedef struct netdata_string STRING;
+
+STRING *string_strdupz(const char *str);
+STRING *string_strndupz(const char *str, size_t len);
+
+STRING *string_dup(STRING *string);
+void string_freez(STRING *string);
+size_t string_strlen(STRING *string);
+const char *string2str(STRING *string) NEVERNULL;
+
+// keep common prefix/suffix and replace everything else with [x]
+STRING *string_2way_merge(STRING *a, STRING *b);
+
+static inline int string_cmp(STRING *s1, STRING *s2) {
+ // STRINGs are deduplicated, so the same strings have the same pointer
+ // when they differ, we do the typical strcmp() comparison
+ return (s1 == s2)?0:strcmp(string2str(s1), string2str(s2));
+}
+
+static inline int string_strcmp(STRING *string, const char *s) {
+ return strcmp(string2str(string), s);
+}
+
+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);
+
+int string_unittest(size_t entries);
+
+#endif