aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/hash-help.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-11-05 00:09:50 +0100
committerMattias Andrée <maandree@kth.se>2017-11-05 00:09:50 +0100
commit9e8dec188d55ca1f0a3b33acab702ced8ed07a18 (patch)
treecbb43c22e72674dc672e645e6596358e3868568e /src/libmdsserver/hash-help.h
parenttypo (diff)
downloadmds-9e8dec188d55ca1f0a3b33acab702ced8ed07a18.tar.gz
mds-9e8dec188d55ca1f0a3b33acab702ced8ed07a18.tar.bz2
mds-9e8dec188d55ca1f0a3b33acab702ced8ed07a18.tar.xz
Work on changing style, and an important typo fix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/libmdsserver/hash-help.h')
-rw-r--r--src/libmdsserver/hash-help.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/libmdsserver/hash-help.h b/src/libmdsserver/hash-help.h
index 21676f3..0b51bb8 100644
--- a/src/libmdsserver/hash-help.h
+++ b/src/libmdsserver/hash-help.h
@@ -29,16 +29,16 @@
* @param str The string
* @return The hash of the string
*/
-__attribute__((pure))
-static inline size_t string_hash(const char* str)
+static inline size_t __attribute__((pure))
+string_hash(const char *str)
{
- size_t hash = 0;
-
- if (str != NULL)
- while (*str != '\0')
- hash = hash * 31 + (size_t)(unsigned char)*str++;
-
- return hash;
+ size_t hash = 0;
+
+ if (str)
+ while (*str != '\0')
+ hash = hash * 31 + (size_t)(unsigned char)*str++;
+
+ return hash;
}
@@ -49,15 +49,14 @@ static inline size_t string_hash(const char* str)
* @param str_b The second string
* @return Whether the strings are equals
*/
-__attribute__((pure))
-static inline int string_comparator(char* str_a, char* str_b)
+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;
+ if (str_a && str_b && str_a != str_b)
+ return !strcmp(str_a, str_b);
+ else
+ return str_a == str_b;
}
#endif
-