r18436: converted ldb to use talloc_move() instead of talloc_steal() when
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Sep 2006 00:10:38 +0000 (00:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:29 +0000 (14:18 -0500)
appropriate.

Note that I also removed the error checks that were being done on the
result of talloc_steal(). They are pointless as talloc_steal() doesn't
have any failure modes that wouldn't cause a segv anyway, and they
tend to clutter the code
(This used to be commit c0d9e7d473b8e3eb2524a9fc29cf88680f994b36)

source4/lib/ldb/common/ldb.c
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
source4/lib/ldb/ldb_tdb/ldb_index.c
source4/lib/ldb/ldb_tdb/ldb_search.c
source4/lib/ldb/modules/asq.c
source4/lib/ldb/modules/objectclass.c
source4/lib/ldb/modules/paged_results.c
source4/lib/ldb/modules/sort.c
source4/lib/ldb/tools/ad2oLschema.c
source4/lib/ldb/tools/ldbsearch.c

index 991a810135bc23fda53c7f11f02c36136fd9b567..50ec106d84a96951d3d3198517bb3e02010190b2 100644 (file)
@@ -528,11 +528,7 @@ static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ld
 
                res->msgs[res->count + 1] = NULL;
 
-               res->msgs[res->count] = talloc_steal(res->msgs, ares->message);
-               if (! res->msgs[res->count]) {
-                       goto error;
-               }
-
+               res->msgs[res->count] = talloc_move(res->msgs, ares->message);
                res->count++;
        }
 
@@ -548,15 +544,12 @@ static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ld
                        goto error;
                }
 
-               res->refs[n] = talloc_steal(res->refs, ares->referral);
+               res->refs[n] = talloc_move(res->refs, ares->referral);
                res->refs[n + 1] = NULL;
        }
 
        if (ares->controls) {
-               res->controls = talloc_steal(res, ares->controls);
-               if (! res->controls) {
-                       goto error;
-               }
+               res->controls = talloc_move(res, ares->controls);
        }
 
        talloc_free(ares);
index 0f6391d7eb1806c73e2473a5c1fd5502ef06c403..b826a31b405354a92afc6e83aa6e2f1fbb3680c7 100644 (file)
@@ -249,9 +249,7 @@ static void ildb_callback(struct ldap_request *req)
                                        return;
                                }
                                
-                               if (msg->controls) {
-                                       ares->controls = talloc_steal(ares, msg->controls);
-                               }
+                               ares->controls = talloc_move(ares, msg->controls);
                                if (msg->r.SearchResultDone.resultcode) {
                                        if (msg->r.SearchResultDone.errormessage) {
                                                ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage);
@@ -280,7 +278,7 @@ static void ildb_callback(struct ldap_request *req)
                                        return;
                                }
                                ares->message->num_elements = search->num_attributes;
-                               ares->message->elements = talloc_steal(ares->message, search->attributes);
+                               ares->message->elements = talloc_move(ares->message, search->attributes);
 
                                handle->status = LDB_SUCCESS;
                                handle->state = LDB_ASYNC_PENDING;
@@ -383,7 +381,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ildb_ac->req = talloc_steal(ildb_ac, req);
+       ildb_ac->req = talloc_move(ildb_ac, req);
        talloc_free(req->time_event);
        req->time_event = NULL;
        if (timeout) {
index dcac88a6b944b8e9ab88745231a6800f1f130c37..9d71b9e8e85c9af9280fba132d1c9786aea3c922 100644 (file)
@@ -865,11 +865,7 @@ static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, str
 
                res->msgs[res->count + 1] = NULL;
 
-               res->msgs[res->count] = talloc_steal(res->msgs, ares->message);
-               if (! res->msgs[res->count]) {
-                       goto error;
-               }
-
+               res->msgs[res->count] = talloc_move(res->msgs, ares->message);
                res->count++;
        } else {
                ldb_debug(ldb, LDB_DEBUG_ERROR, "unrecognized async reply in ltdb_search_sync_callback!\n");
index b628c31b095d2c19d159310f9c29146e8bd74e32..f2816ec1dafce4e1ac531cde3e14f11bfd4c3f54 100644 (file)
@@ -378,7 +378,7 @@ static int list_intersect(struct ldb_context *ldb,
        for (i=0;i<list->count;i++) {
                if (ldb_list_find(list->dn[i], list2->dn, list2->count, 
                              sizeof(char *), (comparison_fn_t)strcmp) != -1) {
-                       list3->dn[list3->count] = talloc_steal(list3->dn, list->dn[i]);
+                       list3->dn[list3->count] = talloc_move(list3->dn, list->dn[i]);
                        list3->count++;
                } else {
                        talloc_free(list->dn[i]);
@@ -386,7 +386,7 @@ static int list_intersect(struct ldb_context *ldb,
        }
 
        talloc_free(list->dn);
-       list->dn = talloc_steal(list, list3->dn);
+       list->dn = talloc_move(list, list3->dn);
        list->count = list3->count;
        talloc_free(list3);
 
@@ -486,7 +486,7 @@ static int ltdb_index_dn_or(struct ldb_module *module,
 
                if (ret == -1) {
                        ret = 1;
-                       list->dn = talloc_steal(list, list2->dn);
+                       list->dn = talloc_move(list, list2->dn);
                        list->count = list2->count;
                } else {
                        if (list_union(ldb, list, list2) == -1) {
@@ -567,7 +567,7 @@ static int ltdb_index_dn_and(struct ldb_module *module,
                if (ret == -1) {
                        ret = 1;
                        talloc_free(list->dn);
-                       list->dn = talloc_steal(list, list2->dn);
+                       list->dn = talloc_move(list, list2->dn);
                        list->count = list2->count;
                } else {
                        if (list_intersect(ldb, list, list2) == -1) {
index 6a35595d5247eafd4ebbabdae53f4474bb463622..612ca5c0fe4bedcaa17609442a408ad8797bba90 100644 (file)
@@ -312,7 +312,7 @@ int ltdb_add_attr_results(struct ldb_module *module,
 
        (*res) = res2;
 
-       (*res)[*count] = talloc_steal(*res, msg2);
+       (*res)[*count] = talloc_move(*res, msg2);
        (*res)[(*count)+1] = NULL;
        (*count)++;
 
index a06dd5391a5789a3932c56b685fd5877240b98e3..75afae2c7e78493bf2be5e3ac2c015b7ea512e61 100644 (file)
@@ -117,7 +117,7 @@ static int asq_terminate(struct ldb_handle *handle)
 
        if (ac->controls) {
                for (i = 0; ac->controls[i]; i++);
-               ares->controls = talloc_steal(ares, ac->controls);
+               ares->controls = talloc_move(ares, ac->controls);
        } else {
                i = 0;
        }
@@ -162,7 +162,7 @@ static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_
 
        /* we are interested only in the single reply (base search) we receive here */
        if (ares->type == LDB_REPLY_ENTRY) {
-               ac->base_res = talloc_steal(ac, ares);
+               ac->base_res = talloc_move(ac, ares);
        } else {
                talloc_free(ares);
        }
index 9f9e8dadae2b01ecdc52c66e5cfcaa7c9a69d788..fb7cd5db5e09471ec0144e10c8952ea333d7aa9b 100644 (file)
@@ -439,7 +439,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
-               ac->search_res = talloc_steal(ac, ares);
+               ac->search_res = talloc_move(ac, ares);
        } else {
                talloc_free(ares);
        }
index 52d26502ee8efcf5ca3da8fa11eb0c2f5f54394f..43c3fc0246bba09a05d7d3b617b874d96162d7d6 100644 (file)
@@ -190,10 +190,7 @@ static int paged_search_callback(struct ldb_context *ldb, void *context, struct
 
                ac->store->num_entries++;
 
-               ac->store->last->r = talloc_steal(ac->store->last, ares);
-               if (ac->store->last->r == NULL) {
-                       goto error;
-               }
+               ac->store->last->r = talloc_move(ac->store->last, ares);
                ac->store->last->next = NULL;
        }
 
@@ -208,19 +205,13 @@ static int paged_search_callback(struct ldb_context *ldb, void *context, struct
                        goto error;
                }
 
-               ac->store->last_ref->r = talloc_steal(ac->store->last, ares);
-               if (ac->store->last_ref->r == NULL) {
-                       goto error;
-               }
+               ac->store->last_ref->r = talloc_move(ac->store->last, ares);
                ac->store->last_ref->next = NULL;
        }
 
        if (ares->type == LDB_REPLY_DONE) {
                if (ares->controls) {
-                       ac->store->controls = talloc_steal(ac->store, ares->controls);
-                       if (! ac->store->controls) {
-                               goto error;
-                       }
+                       ac->store->controls = talloc_move(ac->store, ares->controls);
                }
                talloc_free(ares);
        }
@@ -394,7 +385,7 @@ static int paged_results(struct ldb_handle *handle)
                ares->controls = ac->store->controls;
                while (ares->controls[i]) i++; /* counting */
 
-               ares->controls = talloc_steal(ares, ac->store->controls);
+               ares->controls = talloc_move(ares, ac->store->controls);
                num_ctrls += i;
        }
 
index 0ae16d08ab9a265b703764f283bd5f0bb216315b..acee40833be96a086f3792ba602a4941bb3d0806 100644 (file)
@@ -185,11 +185,7 @@ static int server_sort_search_callback(struct ldb_context *ldb, void *context, s
 
                ac->msgs[ac->num_msgs + 1] = NULL;
 
-               ac->msgs[ac->num_msgs] = talloc_steal(ac->msgs, ares->message);
-               if (! ac->msgs[ac->num_msgs]) {
-                       goto error;
-               }
-
+               ac->msgs[ac->num_msgs] = talloc_move(ac->msgs, ares->message);
                ac->num_msgs++;
        }
 
@@ -200,22 +196,13 @@ static int server_sort_search_callback(struct ldb_context *ldb, void *context, s
                }
 
                ac->referrals[ac->num_refs + 1] = NULL;
-
-               ac->referrals[ac->num_refs] = talloc_steal(ac->referrals, ares->referral);
-               if (! ac->referrals[ac->num_refs]) {
-                       goto error;
-               }
+               ac->referrals[ac->num_refs] = talloc_move(ac->referrals, ares->referral);
 
                ac->num_refs++;
        }
 
        if (ares->type == LDB_REPLY_DONE) {
-               if (ares->controls) {
-                       ac->controls = talloc_steal(ac, ares->controls);
-                       if (! ac->controls) {
-                               goto error;
-                       }
-               }
+               ac->controls = talloc_move(ac, ares->controls);
        }
 
        talloc_free(ares);
@@ -343,7 +330,7 @@ static int server_sort_results(struct ldb_handle *handle)
                }
 
                ares->type = LDB_REPLY_ENTRY;
-               ares->message = talloc_steal(ares, ac->msgs[i]);
+               ares->message = talloc_move(ares, ac->msgs[i]);
                
                handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
                if (handle->status != LDB_SUCCESS) {
@@ -359,7 +346,7 @@ static int server_sort_results(struct ldb_handle *handle)
                }
 
                ares->type = LDB_REPLY_REFERRAL;
-               ares->referral = talloc_steal(ares, ac->referrals[i]);
+               ares->referral = talloc_move(ares, ac->referrals[i]);
                
                handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
                if (handle->status != LDB_SUCCESS) {
@@ -374,7 +361,7 @@ static int server_sort_results(struct ldb_handle *handle)
        }
 
        ares->type = LDB_REPLY_DONE;
-       ares->controls = talloc_steal(ares, ac->controls);
+       ares->controls = talloc_move(ares, ac->controls);
                
        handle->status = ac->up_callback(ac->module->ldb, ac->up_context, ares);
        if (handle->status != LDB_SUCCESS) {
index c25839290fde30069b2e77549afe220715bc8f68..dae3778d82faeaf73aa718834c65c515c94fc5f1 100644 (file)
@@ -139,7 +139,7 @@ static int fetch_oc_recursive(struct ldb_context *ldb, struct ldb_dn *schemadn,
                if (!res_list->msgs) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
-               res_list->msgs[res_list->count] = talloc_steal(res_list, search_from->msgs[i]);
+               res_list->msgs[res_list->count] = talloc_move(res_list, search_from->msgs[i]);
                res_list->count++;
                res_list->msgs[res_list->count] = NULL;
 
@@ -191,7 +191,7 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       *objectclasses_res = talloc_steal(mem_ctx, ret_res);
+       *objectclasses_res = talloc_move(mem_ctx, ret_res);
        return ret;
 }
 
@@ -280,7 +280,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
                        p++;
                        oid_map = talloc_realloc(mem_ctx, oid_map, struct oid_map, num_maps + 2);
                        trim_string(line, " ", " ");
-                       oid_map[num_maps].old_oid = talloc_steal(oid_map, line);
+                       oid_map[num_maps].old_oid = talloc_move(oid_map, line);
                        trim_string(p, " ", " ");
                        oid_map[num_maps].new_oid = p;
                        num_maps++;
@@ -288,7 +288,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
                } else {
                        attrs_skip = talloc_realloc(mem_ctx, attrs_skip, const char *, num_skip + 2);
                        trim_string(line, " ", " ");
-                       attrs_skip[num_skip] = talloc_steal(attrs_skip, line);
+                       attrs_skip[num_skip] = talloc_move(attrs_skip, line);
                        num_skip++;
                        attrs_skip[num_skip] = NULL;
                }
index e6b8a48a95857b3915429c09abc4dee59d2efe9b..181d857efc6a7f6bb5168ff9a5450bee5f64920e 100644 (file)
@@ -81,12 +81,7 @@ static int store_message(struct ldb_message *msg, struct search_context *sctx) {
                return -1;
        }
 
-       sctx->store[sctx->num_stored] = talloc_steal(sctx->store, msg);
-       if (!sctx->store[sctx->num_stored]) {
-               fprintf(stderr, "talloc_steal failed while storing messages\n");
-               return -1;
-       }
-
+       sctx->store[sctx->num_stored] = talloc_move(sctx->store, msg);
        sctx->num_stored++;
        sctx->store[sctx->num_stored] = NULL;
 
@@ -101,12 +96,7 @@ static int store_referral(char *referral, struct search_context *sctx) {
                return -1;
        }
 
-       sctx->refs_store[sctx->refs] = talloc_steal(sctx->refs_store, referral);
-       if (!sctx->refs_store[sctx->refs]) {
-               fprintf(stderr, "talloc_steal failed while storing referrals\n");
-               return -1;
-       }
-
+       sctx->refs_store[sctx->refs] = talloc_move(sctx->refs_store, referral);
        sctx->refs++;
        sctx->refs_store[sctx->refs] = NULL;