aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-22 11:29:24 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-22 11:29:24 +0200
commit7617fd80db4871a1ccfaff243ba5bf7b48f7b379 (patch)
tree6a7ef096dd1f8a9ccc0c4824f234d2be8290c3af /src/libmdsserver
parentadd string hasher (diff)
downloadmds-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 'src/libmdsserver')
-rw-r--r--src/libmdsserver/hash-help.h18
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