summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2023-09-03 21:22:36 +0200
committercgzones <cgzones@googlemail.com>2024-03-27 19:49:23 +0100
commit4e340c1817aaf61068aa746aad00197d969250b3 (patch)
tree7336068b3bf4fcf0c31d750a1bb1fd31735d0f1b
parentcbcfc5f7d08e210a3477071607a3195fa31f06a3 (diff)
Introduce String_eq_nullable()
-rw-r--r--XUtils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/XUtils.h b/XUtils.h
index 68b94836..32bc282d 100644
--- a/XUtils.h
+++ b/XUtils.h
@@ -54,6 +54,16 @@ static inline bool String_eq(const char* s1, const char* s2) {
return strcmp(s1, s2) == 0;
}
+static inline bool String_eq_nullable(const char* s1, const char* s2) {
+ if (s1 == s2)
+ return true;
+
+ if (s1 && s2)
+ return String_eq(s1, s2);
+
+ return false;
+}
+
ATTR_NONNULL
char* String_cat(const char* s1, const char* s2) ATTR_MALLOC;

© 2014-2024 Faster IT GmbH | imprint | privacy policy