diff options
author | Timo Teras <timo.teras@iki.fi> | 2008-11-27 20:25:01 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2008-11-27 20:25:01 +0200 |
commit | f0609951b9fd2938c0f30853e0aa6b08b8698a88 (patch) | |
tree | 3b1f72cbaad90d715d60643c0fac98b7aaedd37e /src/blob.c | |
parent | 1a7f3e3678844165d2660ebff09da26b9ba01576 (diff) | |
download | apk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.tar.gz apk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.tar.bz2 apk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.tar.xz apk-tools-f0609951b9fd2938c0f30853e0aa6b08b8698a88.zip |
hash, db: use apk_blob_t and list_*
Diffstat (limited to 'src/blob.c')
-rw-r--r-- | src/blob.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -71,6 +71,26 @@ int apk_blob_splitstr(apk_blob_t blob, const char *split, apk_blob_t *l, apk_blo } } +unsigned long apk_blob_hash(apk_blob_t blob) +{ + unsigned long hash = 5381; + int i; + + for (i = 0; i < blob.len; i++) + hash = hash * 33 + blob.ptr[i]; + + return hash; +} + +int apk_blob_compare(apk_blob_t a, apk_blob_t b) +{ + if (a.len == b.len) + return memcmp(a.ptr, b.ptr, a.len); + if (a.len < b.len) + return -1; + return 1; +} + int apk_blob_for_each_segment(apk_blob_t blob, const char *split, int (*cb)(void *ctx, apk_blob_t blob), void *ctx) { |