diff options
-rw-r--r-- | src/libmdsserver/hash-help.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libmdsserver/hash-help.h b/src/libmdsserver/hash-help.h index 7fe87ad..ea8d371 100644 --- a/src/libmdsserver/hash-help.h +++ b/src/libmdsserver/hash-help.h @@ -28,7 +28,7 @@ * @param str The string * @return The hash of the string */ -static inline size_t __attribute__((const)) string_hash(const char* str) +static inline size_t __attribute__((pure)) string_hash(const char* str) { size_t hash = 0; @@ -40,5 +40,21 @@ static inline size_t __attribute__((const)) string_hash(const char* str) } +/** + * Check whether two char* are of equal value + * + * @param str_a The first string + * @param str_b The second string + * @return Whether the strings are equals + */ +static inline int __attribute__((pure)) string_comparator(char* str_a, char* str_b) +{ + if ((str_a != NULL) && (str_b != NULL) && (str_a != str_b)) + return !strcmp((char*)str_a, (char*)str_b); + else + return str_a == str_b; +} + + #endif |