Make it possible to set initial hashtable size

Fixes #213.
This commit is contained in:
Petri Lehtinen
2014-12-18 14:43:07 +02:00
parent 5c1d87592a
commit abaae7630e
4 changed files with 16 additions and 1 deletions

View File

@@ -20,6 +20,10 @@
#include "jansson_private.h" /* for container_of() */
#include "hashtable.h"
#ifndef INITIAL_HASHTABLE_ORDER
#define INITIAL_HASHTABLE_ORDER 3
#endif
typedef struct hashtable_list list_t;
typedef struct hashtable_pair pair_t;
typedef struct hashtable_bucket bucket_t;
@@ -184,7 +188,7 @@ int hashtable_init(hashtable_t *hashtable)
size_t i;
hashtable->size = 0;
hashtable->order = 3;
hashtable->order = INITIAL_HASHTABLE_ORDER;
hashtable->buckets = jsonp_malloc(hashsize(hashtable->order) * sizeof(bucket_t));
if(!hashtable->buckets)
return -1;