diff --git a/src/HashMap.c b/src/HashMap.c index 7cb1284..62c47ba 100644 --- a/src/HashMap.c +++ b/src/HashMap.c @@ -7,6 +7,7 @@ typedef struct HashMapBucket { uint32_t hash; + char *key; void *value; } HashMapBucket; @@ -211,7 +212,7 @@ HashMapGet(HashMap * map, const char *key) } void -HashMapIterate(HashMap * map, void (*iteratorFunc) (void *)) +HashMapIterate(HashMap * map, void (*iteratorFunc) (char *, void *)) { size_t i; @@ -226,7 +227,7 @@ HashMapIterate(HashMap * map, void (*iteratorFunc) (void *)) if (bucket) { - iteratorFunc(bucket->value); + iteratorFunc(bucket->key, bucket->value); } } } @@ -244,7 +245,7 @@ HashMapMaxLoadSet(HashMap * map, float load) void * -HashMapSet(HashMap * map, const char *key, void *value) +HashMapSet(HashMap * map, char *key, void *value) { uint32_t hash; size_t index; @@ -275,6 +276,7 @@ HashMapSet(HashMap * map, const char *key, void *value) } bucket->hash = hash; + bucket->key = key; bucket->value = value; map->entries[index] = bucket; map->count++; @@ -284,6 +286,7 @@ HashMapSet(HashMap * map, const char *key, void *value) if (!bucket->hash) { bucket->hash = hash; + bucket->key = key; bucket->value = value; break; } diff --git a/src/include/HashMap.h b/src/include/HashMap.h index b9e898d..ad23363 100644 --- a/src/include/HashMap.h +++ b/src/include/HashMap.h @@ -49,7 +49,7 @@ extern void * use HashMapDelete. */ extern void * - HashMapSet(HashMap * map, const char *key, void *value); + HashMapSet(HashMap * map, char *key, void *value); /* * HashMapGet: Get the value for the given key. @@ -70,7 +70,7 @@ extern void * HashMapDelete(HashMap * map, const char *key); extern void - HashMapIterate(HashMap * map, void (*iteratorFunc) (void *)); + HashMapIterate(HashMap * map, void (*iteratorFunc) (char *, void *)); /* * HashMapFree: Free the hash map, returning its memory to the operating diff --git a/src/include/Json.h b/src/include/Json.h index b5450fa..ec1124a 100644 --- a/src/include/Json.h +++ b/src/include/Json.h @@ -63,10 +63,10 @@ extern JsonValue * extern void * JsonValueFree(JsonValue * value); -extern char * - JsonEncode(HashMap * object); +extern int + JsonEncode(HashMap * object, FILE * out); extern HashMap * - JsonDecode(char *string); + JsonDecode(FILE * in); #endif