r6470: Remove ldb_search_free() it is not needed anymore.
authorSimo Sorce <idra@samba.org>
Mon, 25 Apr 2005 12:46:18 +0000 (12:46 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:11:40 +0000 (13:11 -0500)
Just use talloc_free() to release the memory after an ldb_search().

20 files changed:
source/dsdb/samdb/ldb_modules/samldb.c
source/dsdb/samdb/samdb.c
source/lib/ldb/common/ldb.c
source/lib/ldb/common/ldb_modules.c
source/lib/ldb/include/ldb.h
source/lib/ldb/include/ldb_private.h
source/lib/ldb/ldb_ldap/ldb_ldap.c
source/lib/ldb/ldb_tdb/ldb_search.c
source/lib/ldb/ldb_tdb/ldb_tdb.c
source/lib/ldb/ldb_tdb/ldb_tdb.h
source/lib/ldb/man/man3/ldb.yo
source/lib/ldb/modules/schema.c
source/lib/ldb/modules/skel.c
source/lib/ldb/modules/timestamps.c
source/lib/ldb/tools/ldbdel.c
source/lib/ldb/tools/ldbedit.c
source/lib/ldb/tools/ldbsearch.c
source/lib/ldb/tools/ldbtest.c
source/lib/registry/reg_backend_ldb.c
source/rpc_server/samr/dcesrv_samr.c

index 7ec1ea1a296dfe18cd287c57a2bda977bd2c0a10..a392f978652b8d215c9af8af7e5f67261f6bde91 100644 (file)
@@ -51,12 +51,6 @@ static int samldb_search(struct ldb_module *module, const char *base,
        return ldb_next_search(module, base, scope, expression, attrs, res);
 }
 
-static int samldb_search_free(struct ldb_module *module, struct ldb_message **res)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_search_free\n");
-       return ldb_next_search_free(module, res);
-}
-
 /*
   allocate a new id, attempting to do it atomically
   return 0 on failure, the id on success
@@ -74,13 +68,13 @@ static int samldb_allocate_next_rid(struct ldb_context *ldb, TALLOC_CTX *mem_ctx
 
        ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, "nextRid=*", attrs, &res);
        if (ret != 1) {
-               if (res) ldb_search_free(ldb, res);
+               if (res) talloc_free(res);
                return -1;
        }
        str = ldb_msg_find_string(res[0], "nextRid", NULL);
        if (str == NULL) {
                ldb_debug(ldb, LDB_DEBUG_FATAL, "attribute nextRid not found in %s\n", dn);
-               ldb_search_free(ldb, res);
+               talloc_free(res);
                return -1;
        }
 
@@ -88,10 +82,10 @@ static int samldb_allocate_next_rid(struct ldb_context *ldb, TALLOC_CTX *mem_ctx
        if ((*id)+1 == 0) {
                /* out of IDs ! */
                ldb_debug(ldb, LDB_DEBUG_FATAL, "Are we out of valid IDs ?\n");
-               ldb_search_free(ldb, res);
+               talloc_free(res);
                return -1;
        }
-       ldb_search_free(ldb, res);
+       talloc_free(res);
 
        /* we do a delete and add as a single operation. That prevents
           a race */
@@ -150,7 +144,7 @@ static char *samldb_search_domain(struct ldb_module *module, TALLOC_CTX *mem_ctx
                sdn++;
 
                ret = ldb_search(module->ldb, sdn, LDB_SCOPE_BASE, "objectClass=domain", NULL, &res);
-               ldb_search_free(module->ldb, res);
+               talloc_free(res);
 
                if (ret == 1)
                        break;
@@ -195,14 +189,14 @@ static char *samldb_get_new_sid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
        ret = ldb_search(module->ldb, dom_dn, LDB_SCOPE_BASE, "objectSid=*", attrs, &res);
        if (ret != 1) {
                ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_get_new_sid: error retrieving domain sid!\n");
-               if (res) ldb_search_free(module->ldb, res);
+               if (res) talloc_free(res);
                return NULL;
        }
 
        dom_sid = ldb_msg_find_string(res[0], "objectSid", NULL);
        if (dom_sid == NULL) {
                ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_get_new_sid: error retrieving domain sid!\n");
-               ldb_search_free(module->ldb, res);
+               talloc_free(res);
                return NULL;
        }
 
@@ -218,7 +212,7 @@ static char *samldb_get_new_sid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
        }
        if (ret != 0) {
                ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to increment nextRid of %s\n", dom_dn);
-               ldb_search_free(module->ldb, res);
+               talloc_free(res);
                return NULL;
        }
 
@@ -226,7 +220,8 @@ static char *samldb_get_new_sid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
 
        obj_sid = talloc_asprintf(mem_ctx, "%s-%u", dom_sid, rid);
 
-       ldb_search_free(module->ldb, res);
+       talloc_free(res);
+
 
        return obj_sid;
 }
@@ -349,13 +344,13 @@ static int samldb_copy_template(struct ldb_module *module, struct ldb_message *m
                                                            NULL,
                                                            (char *)el->values[j].data)) {
                                ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Attribute adding failed...\n");
-                               ldb_search_free(module->ldb, res);
+                               talloc_free(res);
                                return -1;
                        }
                }
        }
 
-       ldb_search_free(module->ldb, res);
+       talloc_free(res);
 
        return 0;
 }
@@ -606,7 +601,6 @@ static int samldb_destructor(void *module_ctx)
 static const struct ldb_module_ops samldb_ops = {
        "samldb",
        samldb_search,
-       samldb_search_free,
        samldb_add_record,
        samldb_modify_record,
        samldb_delete_record,
index 6f9251dd327273cec25a19f80fcf0cf3bc515895..b337577ae7f5bcfe5436d7f80bc4bd4ec4dcec7b 100644 (file)
@@ -78,15 +78,6 @@ int samdb_search_domain(struct ldb_context *sam_ldb,
        return count;
 }
 
-/*
-  free up a search result
-*/
-int samdb_search_free(struct ldb_context *sam_ldb,
-                     TALLOC_CTX *mem_ctx, struct ldb_message **res)
-{
-       return ldb_search_free(sam_ldb, res);
-}
-
 /*
   search the sam for a single string attribute in exactly 1 record
 */
@@ -106,7 +97,7 @@ const char *samdb_search_string_v(struct ldb_context *sam_ldb,
                         attr_name, format, count));
        }
        if (count != 1) {
-               samdb_search_free(sam_ldb, mem_ctx, res);
+               talloc_free(res);
                return NULL;
        }
 
@@ -235,14 +226,14 @@ int samdb_search_string_multiple(struct ldb_context *sam_ldb,
                if (res[i]->num_elements != 1) {
                        DEBUG(1,("samdb: search for %s %s not single valued\n", 
                                 attr_name, format));
-                       samdb_search_free(sam_ldb, mem_ctx, res);
+                       talloc_free(res);
                        return -1;
                }
        }
 
        *strs = talloc_array(mem_ctx, const char *, count+1);
        if (! *strs) {
-               samdb_search_free(sam_ldb, mem_ctx, res);
+               talloc_free(res);
                return -1;
        }
 
index 40616c59636c28464f64038b1e66ffb8986e6bd1..600c7063f01a4b400638c1e4b595a7e3c7321b16 100644 (file)
@@ -81,6 +81,9 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
   search the database given a LDAP-like search expression
 
   return the number of records found, or -1 on error
+
+  Use talloc_free to free the ldb_message returned in 'res'
+
 */
 int ldb_search(struct ldb_context *ldb, 
               const char *base,
@@ -91,15 +94,6 @@ int ldb_search(struct ldb_context *ldb,
        return ldb->modules->ops->search(ldb->modules, base, scope, expression, attrs, res);
 }
 
-/* 
-   free a set of messages returned by ldb_search
-*/
-int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs)
-{
-       return ldb->modules->ops->search_free(ldb->modules, msgs);
-}
-
-
 /*
   add a record to the database. Will fail if a record with the given class and key
   already exists
index ffa150d7738f0ef3d486372d6ee00d30299df295..644154d645952f269aba14b751a6a14b9fd2317c 100644 (file)
@@ -224,14 +224,6 @@ int ldb_next_search(struct ldb_module *module,
        return module->next->ops->search(module->next, base, scope, expression, attrs, res);
 }
 
-int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg)
-{
-       if (!module->next) {
-               return -1;
-       }
-       return module->next->ops->search_free(module->next, msg);
-}
-
 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message)
 {
        if (!module->next) {
index 0eb661d7ce64dfd5528c1bbac461ac95ee92ab35..f748bb6b42e3dce18dcf1d83f5919393a7c2dd9e 100644 (file)
@@ -162,6 +162,8 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
   search the database given a LDAP-like search expression
 
   return the number of records found, or -1 on error
+
+  use talloc_free to free the ldb_message returned
 */
 int ldb_search(struct ldb_context *ldb, 
               const char *base,
@@ -169,12 +171,6 @@ int ldb_search(struct ldb_context *ldb,
               const char *expression,
               const char * const *attrs, struct ldb_message ***res);
 
-/* 
-   free a set of messages returned by ldb_search
-*/
-int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs);
-
-
 /*
   add a record to the database. Will fail if a record with the given class and key
   already exists
index a370a802998985da0e3ab0ef92070c977b2326bf..7a0b2fef759002363bd5d0b8a8bbf19efa14b7bb 100644 (file)
@@ -57,7 +57,6 @@ struct ldb_module_ops {
        const char *name;
        int (*search)(struct ldb_module *, const char *, enum ldb_scope,
                      const char *, const char * const [], struct ldb_message ***);
-       int (*search_free)(struct ldb_module *, struct ldb_message **);
        int (*add_record)(struct ldb_module *, const struct ldb_message *);
        int (*modify_record)(struct ldb_module *, const struct ldb_message *);
        int (*delete_record)(struct ldb_module *, const char *);
@@ -89,7 +88,6 @@ int ldb_next_search(struct ldb_module *module,
               enum ldb_scope scope,
               const char *expression,
               const char * const *attrs, struct ldb_message ***res);
-int ldb_next_search_free(struct ldb_module *module, struct ldb_message **msg);
 int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
 int ldb_next_delete_record(struct ldb_module *module, const char *dn);
index dc392dd56b0fa562cb9368532fb6b0d0bf4071aa..c62c1b9e560318a180716b3f122dde65a6f12ff6 100644 (file)
@@ -125,16 +125,6 @@ static int lldb_delete(struct ldb_module *module, const char *dn)
        return ret;
 }
 
-/*
-  free a search result
-*/
-static int lldb_search_free(struct ldb_module *module, struct ldb_message **res)
-{
-       talloc_free(res);
-       return 0;
-}
-
-
 /*
   add a single set of ldap message values to a ldb_message
 */
@@ -290,7 +280,7 @@ static int lldb_search(struct ldb_module *module, const char *base,
        return msg_count;
 
 failed:
-       if (*res) lldb_search_free(module, *res);
+       if (*res) talloc_free(*res);
        return -1;
 }
 
@@ -459,7 +449,6 @@ static const char *lldb_errstring(struct ldb_module *module)
 static const struct ldb_module_ops lldb_ops = {
        "ldap",
        lldb_search,
-       lldb_search_free,
        lldb_add,
        lldb_modify,
        lldb_delete,
index f813841edb03b4a081f4a17d8fb0bd8c454393bd..4f45fdf37678cacc8cc2641b53c72009edf783f9 100644 (file)
@@ -415,20 +415,6 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
 }
 
 
-/*
-  free a set of search results
-*/
-int ltdb_search_free(struct ldb_module *module, struct ldb_message **msgs)
-{
-       struct ltdb_private *ltdb = module->private_data;
-
-       ltdb->last_err_string = NULL;
-       
-       talloc_free(msgs);
-
-       return 0;
-}
-
 /*
   search the database with a LDAP-like expression.
   this is the "full search" non-indexed variant
index 204eaf9d3cd25b68b9ae1da3b4e049a898cf8de9..87582cf4eba2b921e439f24540c7d7bdb9490774 100644 (file)
@@ -797,7 +797,6 @@ static const char *ltdb_errstring(struct ldb_module *module)
 static const struct ldb_module_ops ltdb_ops = {
        "tdb",
        ltdb_search,
-       ltdb_search_free,
        ltdb_add,
        ltdb_modify,
        ltdb_delete,
index 4c2fc52f7c8f1ee9206f16189a646fb83e85b846..9fb60b6359f134ac6f19651f08d6e1ed84281a6a 100644 (file)
@@ -95,7 +95,6 @@ int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
                          const char * const attrs[], 
                          int *count, 
                          struct ldb_message ***res);
-int ltdb_search_free(struct ldb_module *module, struct ldb_message **msgs);
 int ltdb_search(struct ldb_module *module, const char *base,
                enum ldb_scope scope, const char *expression,
                const char * const attrs[], struct ldb_message ***res);
index 8d7a60ccf26300ec2739d7f67d06a2b20674cedc..c2c7e1b8722bc8d46cb0c769221ddf9b61a51b5f 100644 (file)
@@ -66,8 +66,6 @@ dit(bf(ldb_connect(3))) connect to a ldb backend
 
 dit(bf(ldb_search(3))) perform a database search
 
-dit(bf(ldb_search_free(3))) free the results of a ldb_search
-
 dit(bf(ldb_add(3))) add a record to the database
 
 dit(bf(ldb_delete(3))) delete a record from the database
index 4502bba9ed82919ee440aa56f3eb402633e96961..29e519441603c03d956a4b0d0b85a57f7ad5ea03 100644 (file)
@@ -166,7 +166,7 @@ static int get_entry_attributes(struct ldb_context *ldb, const char *dn, struct
        /* set flags to 0 as flags on search have undefined values */
        ret = get_msg_attributes(ss, *srch, 0);
        if (ret != 0) {
-               ldb_search_free(ldb, srch);
+               talloc_free(srch);
                return ret;
        }
 
@@ -306,12 +306,6 @@ static int schema_search(struct ldb_module *module, const char *base,
        return ldb_next_search(module, base, scope, expression, attrs, res); 
 }
 
-/* search_free */
-static int schema_search_free(struct ldb_module *module, struct ldb_message **res)
-{
-       return ldb_next_search_free(module, res);
-}
-
 /* add_record */
 static int schema_add_record(struct ldb_module *module, const struct ldb_message *msg)
 {
@@ -549,7 +543,6 @@ static int schema_destructor(void *module_ctx)
 static const struct ldb_module_ops schema_ops = {
        "schema",
        schema_search,
-       schema_search_free,
        schema_add_record,
        schema_modify_record,
        schema_delete_record,
index 882a7768198a2c545271ddeeb885302dabf0666c..09f24523652c612b4b215745abf9d9676dcf1d44 100644 (file)
@@ -44,12 +44,6 @@ static int skel_search(struct ldb_module *module, const char *base,
        return ldb_next_search(module, base, scope, expression, attrs, res); 
 }
 
-/* search_free */
-static int skel_search_free(struct ldb_module *module, struct ldb_message **res)
-{
-       return ldb_next_search_free(module, res);
-}
-
 /* add_record */
 static int skel_add_record(struct ldb_module *module, const struct ldb_message *msg)
 {
@@ -102,7 +96,6 @@ static int skel_destructor(void *module_ctx)
 static const struct ldb_module_ops skel_ops = {
        "skel",
        skel_search,
-       skel_search_free,
        skel_add_record,
        skel_modify_record,
        skel_delete_record,
index c472fc3c5528614248185ed1b5cc204c2a0b097e..1c01bd14fdd84ac77ea56449873641701c053165 100644 (file)
@@ -49,12 +49,6 @@ static int timestamps_search(struct ldb_module *module, const char *base,
        return ldb_next_search(module, base, scope, expression, attrs, res);
 }
 
-static int timestamps_search_free(struct ldb_module *module, struct ldb_message **res)
-{
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_search_free\n");
-       return ldb_next_search_free(module, res);
-}
-
 static int add_time_element(struct ldb_module *module, struct ldb_message *msg, 
                            const char *attr_name, const char *time_string, unsigned int flags)
 {
@@ -255,7 +249,6 @@ static int timestamps_destructor(void *module_ctx)
 static const struct ldb_module_ops timestamps_ops = {
        "timestamps",
        timestamps_search,
-       timestamps_search_free,
        timestamps_add_record,
        timestamps_modify_record,
        timestamps_delete_record,
index 72540db07ae507a102731f08a158e69c2f9622f5..ec2e302b20036e165ef0aeb89c3fcd2f58a37aea 100644 (file)
@@ -55,7 +55,7 @@ static int ldb_delete_recursive(struct ldb_context *ldb, const char *dn)
                }
        }
 
-       ldb_search_free(ldb, res);
+       talloc_free(res);
 
        if (total == 0) {
                return -1;
index b9f82c282a18a402fabc564557a238bc7838ede4..4c41b6b19a64d47e7181dac9d99d2470e6b978f1 100644 (file)
@@ -427,9 +427,9 @@ static void usage(void)
        do_edit(ldb, msgs, ret, editor);
 
        if (ret > 0) {
-               ret = ldb_search_free(ldb, msgs);
+               ret = talloc_free(msgs);
                if (ret == -1) {
-                       fprintf(stderr, "search_free failed - %s\n", ldb_errstring(ldb));
+                       fprintf(stderr, "talloc_free failed\n");
                        exit(1);
                }
        }
index 8d435e76613d5211afad15e249bcdf08b1e00e17..3e6e7d7febd7baf185882a264ff1bad6a7ed389d 100644 (file)
@@ -81,9 +81,9 @@ static int do_search(struct ldb_context *ldb,
        }
 
        if (ret > 0) {
-               ret = ldb_search_free(ldb, msgs);
+               ret = talloc_free(msgs);
                if (ret == -1) {
-                       fprintf(stderr, "search_free failed\n");
+                       fprintf(stderr, "talloc_free failed\n");
                        exit(1);
                }
        }
index 86f39d460668bc017e68b836e63301aae02666c6..fc1f3e3098d6c5d28f762fdf33df64f29b8cd349 100644 (file)
@@ -248,7 +248,7 @@ static void search_uid(struct ldb_context *ldb, int nrecords, int nsearches)
                }
 
                if (ret > 0) {
-                       ldb_search_free(ldb, res);
+                       talloc_free(res);
                }
 
                printf("testing uid %d/%d - %d  \r", i, uid, ret);
index 7e63b142451bdaab0725770add3bb2be8df13dce..fc01de61a507075ee058a58e551322ef1d078523 100644 (file)
@@ -102,12 +102,12 @@ static int reg_close_ldb_key (void *data)
        struct ldb_context *c = key->hive->backend_data;
 
        if (kd->subkeys) {
-               ldb_search_free(c, kd->subkeys); 
+               talloc_free(kd->subkeys); 
                kd->subkeys = NULL;
        }
 
        if (kd->values) {
-               ldb_search_free(c, kd->values); 
+               talloc_free(kd->values); 
                kd->values = NULL;
        }
        return 0;
@@ -224,7 +224,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h, const ch
        (*key)->backend_data = newkd = talloc_zero(*key, struct ldb_key_data);
        newkd->dn = talloc_strdup(mem_ctx, msg[0]->dn); 
 
-       ldb_search_free(c, msg);
+       talloc_free(msg);
 
        return WERR_OK;
 }
index c2c0354a515d17690316707423876e0703bb150e..968328fe9d92775ff84cdfd06c7cac1228a37a2c 100644 (file)
@@ -3330,14 +3330,14 @@ static NTSTATUS samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX
                return NT_STATUS_NO_SUCH_DOMAIN;
        }
        if (ret > 1) {
-               samdb_search_free(sam_ctx, mem_ctx, msgs);
+               talloc_free(msgs);
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
        r->out.info.min_password_length = samdb_result_uint(msgs[0], "minPwdLength", 0);
        r->out.info.password_properties = samdb_result_uint(msgs[0], "pwdProperties", 1);
 
-       samdb_search_free(sam_ctx, mem_ctx, msgs);
+       talloc_free(msgs);
 
        talloc_free(sam_ctx);
        return NT_STATUS_OK;