X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=src%2Fhashtable.c;h=de25c2126a704f07834574acf7bf28421906a629;hb=42b651ef56168937d0046bde9205f1014a940941;hp=d66b240e5a2d0db98e1f6a9d1f237de7b2e8b218;hpb=fa7c2ea070672d05b34b6341142a193e9a7d0a8c;p=jansson.git diff --git a/src/hashtable.c b/src/hashtable.c index d66b240..de25c21 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -145,7 +145,7 @@ static void hashtable_do_clear(hashtable_t *hashtable) hashtable->free_key(pair->key); if(hashtable->free_value) hashtable->free_value(pair->value); - free(pair); + jsonp_free(pair); } } @@ -155,12 +155,12 @@ static int hashtable_do_rehash(hashtable_t *hashtable) pair_t *pair; size_t i, index, new_size; - free(hashtable->buckets); + jsonp_free(hashtable->buckets); hashtable->num_buckets++; new_size = num_buckets(hashtable); - hashtable->buckets = malloc(new_size * sizeof(bucket_t)); + hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t)); if(!hashtable->buckets) return -1; @@ -187,13 +187,13 @@ static int hashtable_do_rehash(hashtable_t *hashtable) hashtable_t *hashtable_create(key_hash_fn hash_key, key_cmp_fn cmp_keys, free_fn free_key, free_fn free_value) { - hashtable_t *hashtable = malloc(sizeof(hashtable_t)); + hashtable_t *hashtable = jsonp_malloc(sizeof(hashtable_t)); if(!hashtable) return NULL; if(hashtable_init(hashtable, hash_key, cmp_keys, free_key, free_value)) { - free(hashtable); + jsonp_free(hashtable); return NULL; } @@ -203,7 +203,7 @@ hashtable_t *hashtable_create(key_hash_fn hash_key, key_cmp_fn cmp_keys, void hashtable_destroy(hashtable_t *hashtable) { hashtable_close(hashtable); - free(hashtable); + jsonp_free(hashtable); } int hashtable_init(hashtable_t *hashtable, @@ -214,7 +214,7 @@ int hashtable_init(hashtable_t *hashtable, hashtable->size = 0; hashtable->num_buckets = 0; /* index to primes[] */ - hashtable->buckets = malloc(num_buckets(hashtable) * sizeof(bucket_t)); + hashtable->buckets = jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t)); if(!hashtable->buckets) return -1; @@ -237,7 +237,7 @@ int hashtable_init(hashtable_t *hashtable, void hashtable_close(hashtable_t *hashtable) { hashtable_do_clear(hashtable); - free(hashtable->buckets); + jsonp_free(hashtable->buckets); } int hashtable_set(hashtable_t *hashtable, void *key, void *value) @@ -266,7 +266,7 @@ int hashtable_set(hashtable_t *hashtable, void *key, void *value) } else { - pair = malloc(sizeof(pair_t)); + pair = jsonp_malloc(sizeof(pair_t)); if(!pair) return -1;