From 1a988ec9af7960616fb4661b20d86ff05146d836 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:49:29 +0000 Subject: r4474: - converted ldb to use talloc internally - added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0) --- source4/lib/ldb/common/ldb_modules.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'source4/lib/ldb/common/ldb_modules.c') diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 71ec3fdc00..4f53535bc4 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -57,21 +57,19 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) pn = 0; if (options) { - for (i = 0; options[i] != NULL; i++) { - - if (strncmp(options[i], LDB_MODULE_PREFIX, LDB_MODULE_PREFIX_LEN) == 0) { - - p = q = ldb_strdup(ldb, &options[i][LDB_MODULE_PREFIX_LEN]); + if (strncmp(options[i], LDB_MODULE_PREFIX, + LDB_MODULE_PREFIX_LEN) == 0) { + p = q = talloc_strdup(ldb, &options[i][LDB_MODULE_PREFIX_LEN]); if (*q != ':') { - ldb_free(ldb, q); + talloc_free(q); return -1; } do { *p = '\0'; q = p + 1; pn++; - modules = ldb_realloc_array(ldb, modules, sizeof(char *), pn); + modules = talloc_realloc_p(ldb, modules, char *, pn); if (!modules) { ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n"); return -1; @@ -82,10 +80,12 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) } } - if (!modules && strcmp("ldap", ldb->modules->ops->name)) { /* no modules in the options, look for @MODULES in the db (not for ldap) */ + if (!modules && strcmp("ldap", ldb->modules->ops->name)) { + /* no modules in the options, look for @MODULES in the + db (not for ldap) */ int ret, j, k; const char * const attrs[] = { "@MODULE" , NULL}; - struct ldb_message **msg; + struct ldb_message **msg = NULL; ret = ldb_search(ldb, "", LDB_SCOPE_BASE, "dn=@MODULES", attrs, &msg); if (ret == 0) { @@ -103,12 +103,12 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) for (j = 0; j < msg[0]->num_elements; j++) { for (k = 0; k < msg[0]->elements[j].num_values; k++) { pn++; - modules = ldb_realloc_array(ldb, modules, sizeof(char *), pn); + modules = talloc_realloc_p(ldb, modules, char *, pn); if (!modules) { ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n"); return -1; } - modules[pn - 1] = ldb_strndup(ldb, msg[0]->elements[j].values[k].data, msg[0]->elements[j].values[k].length); + modules[pn - 1] = talloc_strndup(modules, msg[0]->elements[j].values[k].data, msg[0]->elements[j].values[k].length); if (!modules[pn - 1]) { ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n"); return -1; @@ -116,13 +116,11 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) } } } - ldb_search_free(ldb, msg); + talloc_free(msg); } if (modules) { - for (i = 0; i < pn; i++) { - if (strcmp(modules[i], "timestamps") == 0) { current = timestamps_module_init(ldb, options); if (!current) { @@ -274,10 +272,3 @@ const char *ldb_next_errstring(struct ldb_module *module) return module->next->ops->errstring(module->next); } -void ldb_next_cache_free(struct ldb_module *module) -{ - if (!module->next) { - return; - } - module->next->ops->cache_free(module->next); -} -- cgit