1*6a54128fSAndroid Build Coastguard Worker #ifndef HASHMAP_H 2*6a54128fSAndroid Build Coastguard Worker # define HASHMAP_H 3*6a54128fSAndroid Build Coastguard Worker 4*6a54128fSAndroid Build Coastguard Worker # include <stdlib.h> 5*6a54128fSAndroid Build Coastguard Worker # include <stdint.h> 6*6a54128fSAndroid Build Coastguard Worker 7*6a54128fSAndroid Build Coastguard Worker #ifndef __GNUC_PREREQ 8*6a54128fSAndroid Build Coastguard Worker #if defined(__GNUC__) && defined(__GNUC_MINOR__) 9*6a54128fSAndroid Build Coastguard Worker #define __GNUC_PREREQ(maj, min) \ 10*6a54128fSAndroid Build Coastguard Worker ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 11*6a54128fSAndroid Build Coastguard Worker #else 12*6a54128fSAndroid Build Coastguard Worker #define __GNUC_PREREQ(maj, min) 0 13*6a54128fSAndroid Build Coastguard Worker #endif 14*6a54128fSAndroid Build Coastguard Worker #endif 15*6a54128fSAndroid Build Coastguard Worker 16*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap; 17*6a54128fSAndroid Build Coastguard Worker 18*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry { 19*6a54128fSAndroid Build Coastguard Worker void *data; 20*6a54128fSAndroid Build Coastguard Worker const void *key; 21*6a54128fSAndroid Build Coastguard Worker size_t key_len; 22*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry *next; 23*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry *list_next; 24*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry *list_prev; 25*6a54128fSAndroid Build Coastguard Worker }; 26*6a54128fSAndroid Build Coastguard Worker 27*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap *ext2fs_hashmap_create( 28*6a54128fSAndroid Build Coastguard Worker uint32_t(*hash_fct)(const void*, size_t), 29*6a54128fSAndroid Build Coastguard Worker void(*free_fct)(void*), size_t size); 30*6a54128fSAndroid Build Coastguard Worker int ext2fs_hashmap_add(struct ext2fs_hashmap *h, 31*6a54128fSAndroid Build Coastguard Worker void *data, const void *key,size_t key_len); 32*6a54128fSAndroid Build Coastguard Worker void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key, 33*6a54128fSAndroid Build Coastguard Worker size_t key_len); 34*6a54128fSAndroid Build Coastguard Worker void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h, 35*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry **it); 36*6a54128fSAndroid Build Coastguard Worker void ext2fs_hashmap_del(struct ext2fs_hashmap *h, 37*6a54128fSAndroid Build Coastguard Worker struct ext2fs_hashmap_entry *e); 38*6a54128fSAndroid Build Coastguard Worker void ext2fs_hashmap_free(struct ext2fs_hashmap *h); 39*6a54128fSAndroid Build Coastguard Worker 40*6a54128fSAndroid Build Coastguard Worker uint32_t ext2fs_djb2_hash(const void *str, size_t size); 41*6a54128fSAndroid Build Coastguard Worker 42*6a54128fSAndroid Build Coastguard Worker #endif /* !HASHMAP_H */ 43