diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-04-22 11:29:24 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-04-22 11:29:24 +0200 |
commit | 7617fd80db4871a1ccfaff243ba5bf7b48f7b379 (patch) | |
tree | 6a7ef096dd1f8a9ccc0c4824f234d2be8290c3af | |
parent | add string hasher (diff) | |
download | mds-7617fd80db4871a1ccfaff243ba5bf7b48f7b379.tar.gz mds-7617fd80db4871a1ccfaff243ba5bf7b48f7b379.tar.bz2 mds-7617fd80db4871a1ccfaff243ba5bf7b48f7b379.tar.xz |
m + add string comparator
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-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 |