summaryrefslogtreecommitdiffstats
path: root/src/map.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-04 19:25:39 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-09-04 19:25:39 -0400
commit5bd8318b7fbf98d409e5c2fa9255b96d185d670f (patch)
tree09e695dd27967a20198137b4bb05205fa5c8f642 /src/map.c
parent9fadfc240d5a66379576d54c9e14cc8c8148b2f2 (diff)
downloadslapi-nis-5bd8318b7fbf98d409e5c2fa9255b96d185d670f.tar.gz
slapi-nis-5bd8318b7fbf98d409e5c2fa9255b96d185d670f.tar.xz
slapi-nis-5bd8318b7fbf98d409e5c2fa9255b96d185d670f.zip
- track the length of the list of entries kept by a map
- add a way to read the number of entries in a map - add a way to read the number of maps in a domain
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/map.c b/src/map.c
index 3652455..8487a74 100644
--- a/src/map.c
+++ b/src/map.c
@@ -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)
{