diff options
Diffstat (limited to 'libnetdata/string')
-rw-r--r-- | libnetdata/string/README.md | 2 | ||||
-rw-r--r-- | libnetdata/string/string.c | 8 | ||||
-rw-r--r-- | libnetdata/string/string.h | 1 | ||||
-rw-r--r-- | libnetdata/string/utf8.h | 4 |
4 files changed, 10 insertions, 5 deletions
diff --git a/libnetdata/string/README.md b/libnetdata/string/README.md index b1c6e61c..4fd44250 100644 --- a/libnetdata/string/README.md +++ b/libnetdata/string/README.md @@ -4,7 +4,7 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/libnetdata/strin sidebar_label: "String" learn_status: "Published" learn_topic_type: "Tasks" -learn_rel_path: "Developers/libnetdata libraries" +learn_rel_path: "Developers/libnetdata" --> # STRING diff --git a/libnetdata/string/string.c b/libnetdata/string/string.c index 4e232523..9385aa6e 100644 --- a/libnetdata/string/string.c +++ b/libnetdata/string/string.c @@ -300,16 +300,20 @@ void string_freez(STRING *string) { string_stats_atomic_increment(releases); } -size_t string_strlen(STRING *string) { +inline size_t string_strlen(STRING *string) { if(unlikely(!string)) return 0; return string->length - 1; } -const char *string2str(STRING *string) { +inline const char *string2str(STRING *string) { if(unlikely(!string)) return ""; return string->str; } +int string_strcmp(STRING *string, const char *s) { + return strcmp(string2str(string), s); +} + STRING *string_2way_merge(STRING *a, STRING *b) { static STRING *X = NULL; diff --git a/libnetdata/string/string.h b/libnetdata/string/string.h index cec44ebd..70840ee9 100644 --- a/libnetdata/string/string.h +++ b/libnetdata/string/string.h @@ -13,6 +13,7 @@ STRING *string_dup(STRING *string); void string_freez(STRING *string); size_t string_strlen(STRING *string); const char *string2str(STRING *string) NEVERNULL; +int string_strcmp(STRING *string, const char *s); // keep common prefix/suffix and replace everything else with [x] STRING *string_2way_merge(STRING *a, STRING *b); diff --git a/libnetdata/string/utf8.h b/libnetdata/string/utf8.h index 133ec710..3e6c8c28 100644 --- a/libnetdata/string/utf8.h +++ b/libnetdata/string/utf8.h @@ -3,7 +3,7 @@ #ifndef NETDATA_STRING_UTF8_H #define NETDATA_STRING_UTF8_H 1 -#define IS_UTF8_BYTE(x) (x & 0x80) -#define IS_UTF8_STARTBYTE(x) (IS_UTF8_BYTE(x)&&(x & 0x40)) +#define IS_UTF8_BYTE(x) ((x) & 0x80) +#define IS_UTF8_STARTBYTE(x) (IS_UTF8_BYTE(x)&&((x) & 0x40)) #endif /* NETDATA_STRING_UTF8_H */ |