From 4166dd54ebb56083bf61f8d2d4b151c0e476e22c Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 16 Feb 2009 15:49:54 -0500 Subject: Enhancements and bugfixes to util/btreemap.c 1) Remove useless and unused btreemap_new() 2) Fix potentially serious memory allocation error. btreemap now requires a TALLOC_CTX to be passed in for assignment to the top node of the tree. Previously it was creating a new root TALLOC_CTX 3) Add new function btreemap_get_keys that will return a sorted array (newly allocated using talloc_realloc()) of keys (const void *) 4) Change the btreemap to use (const void *) keys instead of (void *) --- server/nss/nsssrv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/nss') diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c index fa43f60f..5a574b41 100644 --- a/server/nss/nsssrv.c +++ b/server/nss/nsssrv.c @@ -48,7 +48,7 @@ static int service_identity(DBusMessage *message, void *data, DBusMessage **r); static int service_pong(DBusMessage *message, void *data, DBusMessage **r); static int service_reload(DBusMessage *message, void *data, DBusMessage **r); static int nss_init_domains(struct nss_ctx *nctx); -static int _domain_comparator(void *key1, void *key2); +static int _domain_comparator(const void *key1, const void *key2); struct sbus_method nss_sbus_methods[] = { {SERVICE_METHOD_IDENTITY, service_identity}, @@ -381,9 +381,9 @@ failed: /* domain names are case insensitive for now * NOTE: this function is not utf-8 safe, * only ASCII names for now */ -static int _domain_comparator(void *key1, void *key2) +static int _domain_comparator(const void *key1, const void *key2) { - return strcasecmp((char *)key1, (char *)key2); + return strcasecmp((const char *)key1, (const char *)key2); } static int nss_init_domains(struct nss_ctx *nctx) @@ -407,7 +407,7 @@ static int nss_init_domains(struct nss_ctx *nctx) /* Look up the appropriate basedn for this domain */ ret = confdb_get_domain_basedn(nctx->cdb, tmp_ctx, domains[i], &basedn); DEBUG(3, ("BaseDN: %s\n", basedn)); - btreemap_set_value(&nctx->domain_map, domains[i], basedn, _domain_comparator); + btreemap_set_value(nctx, &nctx->domain_map, domains[i], basedn, _domain_comparator); i++; } if (i == 0) { -- cgit