summaryrefslogtreecommitdiffstats
path: root/src/hash.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-27 20:25:01 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-27 20:25:01 +0200
commitf0609951b9fd2938c0f30853e0aa6b08b8698a88 (patch)
tree3b1f72cbaad90d715d60643c0fac98b7aaedd37e /src/hash.c
parent1a7f3e3678844165d2660ebff09da26b9ba01576 (diff)
downloadapk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.tar.bz2
apk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.tar.xz
hash, db: use apk_blob_t and list_*
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/hash.c b/src/hash.c
index 447601e..b4bbc90 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -12,22 +12,6 @@
#include "apk_defines.h"
#include "apk_hash.h"
-unsigned long apk_hash_string(const char *str)
-{
- unsigned long hash = 5381;
- int c;
-
- while ((c = *str++) != 0)
- hash = hash * 33 + c;
-
- return hash;
-}
-
-unsigned long apk_hash_csum(const void *ptr)
-{
- return *(const unsigned long *) ptr;
-}
-
void apk_hash_init(struct apk_hash *h, const struct apk_hash_ops *ops,
int num_buckets)
{
@@ -59,13 +43,13 @@ int apk_hash_foreach(struct apk_hash *h, apk_hash_enumerator_f e, void *ctx)
return 0;
}
-apk_hash_item apk_hash_get(struct apk_hash *h, apk_hash_key key)
+apk_hash_item apk_hash_get(struct apk_hash *h, apk_blob_t key)
{
ptrdiff_t offset = h->ops->node_offset;
unsigned long hash;
apk_hash_node *pos;
apk_hash_item item;
- apk_hash_key itemkey;
+ apk_blob_t itemkey;
hash = h->ops->hash_key(key) % h->buckets->num;
hlist_for_each(pos, &h->buckets->item[hash]) {
@@ -80,7 +64,7 @@ apk_hash_item apk_hash_get(struct apk_hash *h, apk_hash_key key)
void apk_hash_insert(struct apk_hash *h, apk_hash_item item)
{
- apk_hash_key key;
+ apk_blob_t key;
unsigned long hash;
apk_hash_node *node;
@@ -91,7 +75,7 @@ void apk_hash_insert(struct apk_hash *h, apk_hash_item item)
h->num_items++;
}
-void apk_hash_delete(struct apk_hash *h, apk_hash_key key)
+void apk_hash_delete(struct apk_hash *h, apk_blob_t key)
{
}