diff --git a/include/common/string-helpers.h b/include/common/string-helpers.h index dca70789..efa5bfd2 100644 --- a/include/common/string-helpers.h +++ b/include/common/string-helpers.h @@ -92,4 +92,13 @@ bool str_endswith_ignore_case(const char *const string, const char *const suffix */ bool str_starts_with(const char *s, char needle, const char *ignore_chars); +/** + * str_equal - indicate whether two strings are identical + * @a: first string to compare + * @b: second string to compare + * + * If both strings are NULL, returns true. + */ +bool str_equal(const char *a, const char *b); + #endif /* LABWC_STRING_HELPERS_H */ diff --git a/src/common/scaled-font-buffer.c b/src/common/scaled-font-buffer.c index 7bd0f1dc..e0d79a57 100644 --- a/src/common/scaled-font-buffer.c +++ b/src/common/scaled-font-buffer.c @@ -10,6 +10,7 @@ #include "common/mem.h" #include "common/scaled-scene-buffer.h" #include "common/scaled-font-buffer.h" +#include "common/string-helpers.h" static struct lab_data_buffer * _create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale) @@ -39,11 +40,6 @@ _destroy(struct scaled_scene_buffer *scaled_buffer) free(self); } -static bool str_equal(const char *a, const char *b) -{ - return a == b || (a && b && !strcmp(a, b)); -} - static bool _equal(struct scaled_scene_buffer *scaled_buffer_a, struct scaled_scene_buffer *scaled_buffer_b) diff --git a/src/common/string-helpers.c b/src/common/string-helpers.c index e517751e..ef29c339 100644 --- a/src/common/string-helpers.c +++ b/src/common/string-helpers.c @@ -200,3 +200,8 @@ str_starts_with(const char *s, char needle, const char *ignore_chars) return (s + strspn(s, ignore_chars))[0] == needle; } +bool +str_equal(const char *a, const char *b) +{ + return a == b || (a && b && !strcmp(a, b)); +}