summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/string/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnetdata/string/string.h')
-rw-r--r--src/libnetdata/string/string.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libnetdata/string/string.h b/src/libnetdata/string/string.h
index c44696be2..e86ac6fb5 100644
--- a/src/libnetdata/string/string.h
+++ b/src/libnetdata/string/string.h
@@ -14,8 +14,10 @@ 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;
+size_t string_strlen(const STRING *string);
+const char *string2str(const STRING *string) NEVERNULL;
+bool string_ends_with_string(const STRING *whole, const STRING *end);
+bool string_starts_with_string(const STRING *whole, const STRING *end);
// keep common prefix/suffix and replace everything else with [x]
STRING *string_2way_merge(STRING *a, STRING *b);
@@ -30,10 +32,21 @@ static inline int string_strcmp(STRING *string, const char *s) {
return strcmp(string2str(string), s);
}
+static inline int string_strncmp(STRING *string, const char *s, size_t n) {
+ return strncmp(string2str(string), s, n);
+}
+
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);
void string_init(void);
+static inline void cleanup_string_pp(STRING **stringpp) {
+ if(stringpp)
+ string_freez(*stringpp);
+}
+
+#define CLEAN_STRING _cleanup_(cleanup_string_pp) STRING
+
#endif