diff options
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -78,6 +78,7 @@ static struct { void *backend_data; void (*free_backend_data)(void *backend_data); } *entries; + int n_unique_entries; /* Search trees to speed up searches for entries. */ unsigned int n_key_trees; void **key_trees; @@ -705,6 +706,7 @@ map_data_clear_map_map(struct plugin_state *state, struct map *map) } free(entry); } + map->n_unique_entries = 0; map->entries = NULL; map->id_tree = NULL; free(map->key_trees); @@ -906,6 +908,7 @@ map_data_unset_map_entry(struct plugin_state *state, if (map->entries == entry) { map->entries = next; } + map->n_unique_entries--; /* Remove every key for this entry from the applicable key * trees. */ for (i = 0; i < entry->n_keys; i++) { @@ -1070,6 +1073,7 @@ map_data_set_entry(struct plugin_state *state, map->entries->prev = entry; } map->entries = entry; + map->n_unique_entries++; /* Index the keys. */ for (i = 0; i < entry->n_keys; i++) { entry->key_index = i; @@ -1139,6 +1143,29 @@ map_done(struct plugin_state *state) map_data.lock = NULL; } +int +map_data_get_domain_size(struct plugin_state *state, const char *domain_name) +{ + struct domain *domain; + domain = map_data_find_domain(state, domain_name); + if (domain != NULL) { + return domain->n_maps; + } + return 0; +} + +int +map_data_get_map_size(struct plugin_state *state, + const char *domain_name, const char *map_name) +{ + struct map *map; + map = map_data_find_map(state, domain_name, map_name); + if (map != NULL) { + return map->n_unique_entries; + } + return 0; +} + void map_rdlock(void) { |