summaryrefslogtreecommitdiffstats
path: root/libnetdata/string
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-08 16:27:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-05-08 16:27:04 +0000
commita836a244a3d2bdd4da1ee2641e3e957850668cea (patch)
treecb87c75b3677fab7144f868435243f864048a1e6 /libnetdata/string
parentAdding upstream version 1.38.1. (diff)
downloadnetdata-a836a244a3d2bdd4da1ee2641e3e957850668cea.tar.xz
netdata-a836a244a3d2bdd4da1ee2641e3e957850668cea.zip
Adding upstream version 1.39.0.upstream/1.39.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/string')
-rw-r--r--libnetdata/string/README.md2
-rw-r--r--libnetdata/string/string.c8
-rw-r--r--libnetdata/string/string.h1
-rw-r--r--libnetdata/string/utf8.h4
4 files changed, 10 insertions, 5 deletions
diff --git a/libnetdata/string/README.md b/libnetdata/string/README.md
index b1c6e61c3..4fd442507 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 4e232523c..9385aa6e8 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 cec44ebd9..70840ee9a 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 133ec710b..3e6c8c288 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 */