dict_t*dict_new()
{
dict_t*d = rfx_alloc(sizeof(dict_t));
- dict_init(d);
+ dict_init(d, INITIAL_SIZE);
return d;
}
dict_t*dict_new2(type_t*t)
{
dict_t*d = rfx_alloc(sizeof(dict_t));
- dict_init(d);
+ dict_init(d, INITIAL_SIZE);
d->key_type = t;
return d;
}
-void dict_init(dict_t*h)
+void dict_init(dict_t*h, int size)
{
memset(h, 0, sizeof(dict_t));
- h->hashsize = INITIAL_SIZE;
+ h->hashsize = size;
h->slots = h->hashsize?(dictentry_t**)rfx_calloc(sizeof(dictentry_t*)*h->hashsize):0;
h->num = 0;
h->key_type = &charptr_type;
map_internal_t*m;
map->internal = (map_internal_t*)rfx_calloc(sizeof(map_internal_t));
m = (map_internal_t*)map->internal;
- dict_init(&m->d);
+ dict_init(&m->d, INITIAL_SIZE);
}
void map_put(map_t*map, string_t t1, string_t t2)
{
dict_t*dict_new();
dict_t*dict_new2(type_t*type);
-void dict_init(dict_t*dict);
+void dict_init(dict_t*dict, int size);
dictentry_t*dict_put(dict_t*h, const void*key, void* data);
int dict_count(dict_t*h);
void dict_dump(dict_t*h, FILE*fi, const char*prefix);
void*array_getkey(array_t*array, int nr);
void*array_getvalue(array_t*array, int nr);
int array_append(array_t*array, const void*name, void*data);
+#define array_contains(a,b) (array_find((a),(b))>=0)
int array_find(array_t*array, const void*name);
int array_find2(array_t*array, const void*name, void*data);
int array_update(array_t*array, const void*name, void*data);
int array_append_if_new(array_t*array, const void*name, void*data);
+#define array_length(a) ((a)->num)
#define DECLARE(x) struct _##x;typedef struct _##x x##_t;
#define DECLARE_LIST(x) \