From 231400ce0c648334529718c53835abfd30bd3eaa Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 25 Jun 2008 15:10:35 -0400 Subject: - don't force the map initialization caller to even bother guessing about the number of keys we'll need --- src/map.c | 7 +++---- src/map.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/map.c b/src/map.c index 73d1550..903a9db 100644 --- a/src/map.c +++ b/src/map.c @@ -686,7 +686,6 @@ void map_data_set_map(struct plugin_state *state, const char *domain_name, const char *map_name, - unsigned int n_keys, bool_t secure, void *backend_data, void (*free_backend_data)(void *backend_data)) @@ -743,8 +742,8 @@ map_data_set_map(struct plugin_state *state, map = &maps[domain->n_maps]; memset(map, 0, sizeof(*map)); map->name = strdup(map_name); - map->key_trees = malloc(n_keys * sizeof(void *)); - map->n_key_trees = n_keys; + map->key_trees = malloc(sizeof(void *)); + map->n_key_trees = (map->key_trees != NULL) ? 1 : 0; map->secure = secure; map->backend_data = backend_data; map->free_backend_data = free_backend_data; @@ -755,7 +754,7 @@ map_data_set_map(struct plugin_state *state, sizeof(*map) * domain->n_maps); /* Clear the key tree set. */ memset(map->key_trees, 0, - n_keys * sizeof(void *)); + map->n_key_trees * sizeof(void *)); /* Switcheroo. */ free(domain->maps); domain->maps = maps; diff --git a/src/map.h b/src/map.h index 30db7bc..3db1c9d 100644 --- a/src/map.h +++ b/src/map.h @@ -71,7 +71,7 @@ void map_data_unset_map(struct plugin_state *state, const char *domain_name, const char *map_name); void map_data_set_map(struct plugin_state *state, const char *domain_name, const char *map_name, - unsigned int n_keys, bool_t secure, + bool_t secure, void *backend_data, void (*free_backend_data)(void *p)); void map_data_unset_entry_id(struct plugin_state *state, const char *domain_name, const char *map_name, -- cgit