replaced TRUE/FALSE by true/false
[free-mc.git] / mhl / strhash.h
blob1f195053c05d33dd7be3982447887191620355a0
1 #ifndef __MHL_STRHASH_H
2 #define __MHL_STRHASH_H
4 #include <hash.h>
5 #include <mhl/memory.h>
7 static void __mhl_strhash_free_key(void* ptr)
9 mhl_mem_free(ptr);
12 static void __mhl_strhash_free_dummy(void* ptr)
16 typedef hash MHL_STRHASH;
18 #define MHL_STRHASH_DECLARE(n) MHL_STRHASH n;
20 #define MHL_STRHASH_INIT(h) \
21 hash_initialise(h, 997U, \
22 hash_hash_string, \
23 hash_compare_string, \
24 hash_copy_string, \
25 __mhl_strhash_free_key, \
26 __mhl_strhash_free_dummy)
28 #define MHL_STRHASH_DECLARE_INIT(n) \
29 MHL_STRHASH_DECLARE(n); \
30 MHL_STRHASH_INIT(&n);
32 #define MHL_STRHASH_DEINIT(ht) \
33 hash_deinitialise(ht)
35 static inline void mhl_strhash_addkey(MHL_STRHASH* ht, const char* key, void* value)
37 hash_insert(ht, (char*)key, value);
40 static inline void* mhl_strhash_lookup(MHL_STRHASH* ht, const char* key)
42 void* retptr;
43 if (hash_retrieve(ht, (char*)key, &retptr))
44 return retptr;
45 else
46 return NULL;
49 #endif