chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journald: increase rate limit burst rate
[elogind.git]
/
src
/
hashmap.c
diff --git
a/src/hashmap.c
b/src/hashmap.c
index 0d89da461406b30b022b0760289acd20e457b217..7ef809746d3a67f0cfbf4220bbcd05bd673bce93 100644
(file)
--- a/
src/hashmap.c
+++ b/
src/hashmap.c
@@
-124,11
+124,13
@@
__attribute__((destructor)) static void cleanup_pool(void) {
#endif
unsigned string_hash_func(const void *p) {
#endif
unsigned string_hash_func(const void *p) {
- unsigned hash = 0;
- const char *c;
+ unsigned hash = 5381;
+ const signed char *c;
+
+ /* DJB's hash function */
for (c = p; *c; c++)
for (c = p; *c; c++)
- hash =
31 *
hash + (unsigned) *c;
+ hash =
(hash << 5) +
hash + (unsigned) *c;
return hash;
}
return hash;
}
@@
-556,6
+558,17
@@
void* hashmap_first(Hashmap *h) {
return h->iterate_list_head->value;
}
return h->iterate_list_head->value;
}
+void* hashmap_first_key(Hashmap *h) {
+
+ if (!h)
+ return NULL;
+
+ if (!h->iterate_list_head)
+ return NULL;
+
+ return (void*) h->iterate_list_head->key;
+}
+
void* hashmap_last(Hashmap *h) {
if (!h)
void* hashmap_last(Hashmap *h) {
if (!h)