1 #ifndef STRINGMAP_H 2 #define STRINGMAP_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 typedef struct stringmap_t stringmap_t; 9 typedef struct stringmap_node_t stringmap_node_t; 10 11 struct stringmap_t { 12 stringmap_node_t *Root; 13 int Size; 14 }; 15 16 #define STRINGMAP_INIT {0,} 17 18 stringmap_t *stringmap_new() __attribute__ ((malloc)); 19 20 void *stringmap_search(const stringmap_t *Map, const char *Key) __attribute__ ((pure)); 21 void *stringmap_insert(stringmap_t *Map, const char *Key, void *Value); 22 void *stringmap_remove(stringmap_t *Map, const char *Key); 23 void **stringmap_slot(stringmap_t *Map, const char *Key); 24 int stringmap_foreach(stringmap_t *Map, void *Data, int (*callback)(const char *, void *, void *)); 25 26 unsigned long stringmap_hash(const char *Key) __attribute__ ((pure)); 27 28 #ifdef __cplusplus 29 } 30 #endif 31 32 #endif 33