hashtable->free_key(pair->key);
if(hashtable->free_value)
hashtable->free_value(pair->value);
- free(pair);
+ jsonp_free(pair);
}
}
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;
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;
}
void hashtable_destroy(hashtable_t *hashtable)
{
hashtable_close(hashtable);
- free(hashtable);
+ jsonp_free(hashtable);
}
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;
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)
}
else
{
- pair = malloc(sizeof(pair_t));
+ pair = jsonp_malloc(sizeof(pair_t));
if(!pair)
return -1;