Use g_strcmp0 for string comparisons

g_strcmp0 handles NULL values correctly. This allows to omit NULL
pointer checks, which would be otherwise crucial.
This commit is contained in:
Benedikt Heine 2019-01-03 19:03:16 +01:00
parent f9f5804b08
commit 8a46b88da9

View File

@ -10,7 +10,7 @@
//! Test if a string is non-NULL and not empty //! Test if a string is non-NULL and not empty
#define STR_FULL(s) !(STR_EMPTY(s)) #define STR_FULL(s) !(STR_EMPTY(s))
//! Test if string a and b contain the same chars //! Test if string a and b contain the same chars
#define STR_EQ(a, b) (strcmp(a, b) == 0) #define STR_EQ(a, b) (g_strcmp0(a, b) == 0)
//! Test if string a and b are same up to n chars //! Test if string a and b are same up to n chars
#define STRN_EQ(a, b, n) (strncmp(a, b, n) == 0) #define STRN_EQ(a, b, n) (strncmp(a, b, n) == 0)
//! Test if string a and b are the same case-insensitively //! Test if string a and b are the same case-insensitively