From 4e340c1817aaf61068aa746aad00197d969250b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 3 Sep 2023 21:22:36 +0200 Subject: Introduce String_eq_nullable() --- XUtils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) 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; -- cgit v1.2.3