r18439: 2nd try at a talloc_move() api. This type with the ** ptr interface
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Sep 2006 02:33:51 +0000 (02:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:18:29 +0000 (14:18 -0500)
exposed.

Unfortunately this generates a large number of type punning
warnings. We'll have to find some magic to hide those.
(This used to be commit 254cbf09dee5a1e20c47e47a298f1a8d172b41b9)

14 files changed:
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
source4/lib/talloc/talloc.3.xml
source4/lib/talloc/talloc.h
source4/lib/talloc/testsuite.c

index 1089fb3d92e5663356f46b5c871cb7852c1a534a..473c6324edb43677b9c906f0d853fe1afa7d82fc 100644 (file)
@@ -528,7 +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_move(res->msgs, ares->message);
+               res->msgs[res->count] = talloc_move(res->msgs, &ares->message);
                res->count++;
        }
 
@@ -544,7 +544,7 @@ static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ld
                        goto error;
                }
 
-               res->refs[n] = talloc_move(res->refs, ares->referral);
+               res->refs[n] = talloc_move(res->refs, &ares->referral);
                res->refs[n + 1] = NULL;
        }
 
index 49a8e8627a4444d8fc35ecc45a21e6e573e29761..5b69ac06c9a16b24054cd4a1a7699b7094743999 100644 (file)
@@ -249,7 +249,7 @@ static void ildb_callback(struct ldap_request *req)
                                        return;
                                }
                                
-                               ares->controls = talloc_move(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);
@@ -278,7 +278,8 @@ static void ildb_callback(struct ldap_request *req)
                                        return;
                                }
                                ares->message->num_elements = search->num_attributes;
-                               ares->message->elements = talloc_move(ares->message, search->attributes);
+                               ares->message->elements = talloc_move(ares->message,
+                                                                     &search->attributes);
 
                                handle->status = LDB_SUCCESS;
                                handle->state = LDB_ASYNC_PENDING;
@@ -391,7 +392,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
 
        req->async.fn = ildb_callback;
        req->async.private_data = (void *)h;
-       ildb_ac->req = talloc_move(ildb_ac, req);
+       ildb_ac->req = talloc_move(ildb_ac, &req);
 
        *handle = h;
        return LDB_SUCCESS;
index 9d71b9e8e85c9af9280fba132d1c9786aea3c922..91256222b1290d444dfa52e9ec7d117fb8c3a806 100644 (file)
@@ -865,7 +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_move(res->msgs, ares->message);
+               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 f2816ec1dafce4e1ac531cde3e14f11bfd4c3f54..59c1645ba8ce4593a1e3e6082da51238061bb28a 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_move(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_move(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_move(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_move(list, list2->dn);
+                       list->dn = talloc_move(list, &list2->dn);
                        list->count = list2->count;
                } else {
                        if (list_intersect(ldb, list, list2) == -1) {
index 612ca5c0fe4bedcaa17609442a408ad8797bba90..7cdb2b672f016580787a3bdfd277dacee96223ef 100644 (file)
@@ -312,7 +312,7 @@ int ltdb_add_attr_results(struct ldb_module *module,
 
        (*res) = res2;
 
-       (*res)[*count] = talloc_move(*res, msg2);
+       (*res)[*count] = talloc_move(*res, &msg2);
        (*res)[(*count)+1] = NULL;
        (*count)++;
 
index 75afae2c7e78493bf2be5e3ac2c015b7ea512e61..229a6eacd94b0b8bb6716869487b818e7f54323d 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_move(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_move(ac, ares);
+               ac->base_res = talloc_move(ac, &ares);
        } else {
                talloc_free(ares);
        }
index fb7cd5db5e09471ec0144e10c8952ea333d7aa9b..493ecdaad401091c850307b9d36d15a8763976b2 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_move(ac, ares);
+               ac->search_res = talloc_move(ac, &ares);
        } else {
                talloc_free(ares);
        }
index 6636efcccbe8f1989bcc267fa441e004d180037b..133ee1fb782296d158ff2454ac005fc82195fae2 100644 (file)
@@ -210,7 +210,7 @@ static int paged_search_callback(struct ldb_context *ldb, void *context, struct
        }
 
        if (ares->type == LDB_REPLY_DONE) {
-               ac->store->controls = talloc_move(ac->store, ares->controls);
+               ac->store->controls = talloc_move(ac->store, &ares->controls);
                talloc_free(ares);
        }
 
@@ -383,7 +383,7 @@ static int paged_results(struct ldb_handle *handle)
                ares->controls = ac->store->controls;
                while (ares->controls[i]) i++; /* counting */
 
-               ares->controls = talloc_move(ares, ac->store->controls);
+               ares->controls = talloc_move(ares, &ac->store->controls);
                num_ctrls += i;
        }
 
index acee40833be96a086f3792ba602a4941bb3d0806..3a0598c5289c40dd5aece7ae74bc3f9e8455ede1 100644 (file)
@@ -185,7 +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_move(ac->msgs, ares->message);
+               ac->msgs[ac->num_msgs] = talloc_move(ac->msgs, &ares->message);
                ac->num_msgs++;
        }
 
@@ -196,13 +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_move(ac->referrals, ares->referral);
+               ac->referrals[ac->num_refs] = talloc_move(ac->referrals, &ares->referral);
 
                ac->num_refs++;
        }
 
        if (ares->type == LDB_REPLY_DONE) {
-               ac->controls = talloc_move(ac, ares->controls);
+               ac->controls = talloc_move(ac, &ares->controls);
        }
 
        talloc_free(ares);
@@ -330,7 +330,7 @@ static int server_sort_results(struct ldb_handle *handle)
                }
 
                ares->type = LDB_REPLY_ENTRY;
-               ares->message = talloc_move(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) {
@@ -346,7 +346,7 @@ static int server_sort_results(struct ldb_handle *handle)
                }
 
                ares->type = LDB_REPLY_REFERRAL;
-               ares->referral = talloc_move(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) {
@@ -361,7 +361,7 @@ static int server_sort_results(struct ldb_handle *handle)
        }
 
        ares->type = LDB_REPLY_DONE;
-       ares->controls = talloc_move(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 dae3778d82faeaf73aa718834c65c515c94fc5f1..23cf892930c9b40a11c6cd5278c891d861305c36 100644 (file)
@@ -139,7 +139,8 @@ 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_move(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 +192,7 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       *objectclasses_res = talloc_move(mem_ctx, ret_res);
+       *objectclasses_res = talloc_move(mem_ctx, &ret_res);
        return ret;
 }
 
@@ -280,7 +281,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_move(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 +289,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_move(attrs_skip, line);
+                       attrs_skip[num_skip] = talloc_move(attrs_skip, &line);
                        num_skip++;
                        attrs_skip[num_skip] = NULL;
                }
index 181d857efc6a7f6bb5168ff9a5450bee5f64920e..23d8115c2010a90738f5e9a250ba4e22e627f227 100644 (file)
@@ -81,7 +81,7 @@ static int store_message(struct ldb_message *msg, struct search_context *sctx) {
                return -1;
        }
 
-       sctx->store[sctx->num_stored] = talloc_move(sctx->store, msg);
+       sctx->store[sctx->num_stored] = talloc_move(sctx->store, &msg);
        sctx->num_stored++;
        sctx->store[sctx->num_stored] = NULL;
 
@@ -96,7 +96,7 @@ static int store_referral(char *referral, struct search_context *sctx) {
                return -1;
        }
 
-       sctx->refs_store[sctx->refs] = talloc_move(sctx->refs_store, referral);
+       sctx->refs_store[sctx->refs] = talloc_move(sctx->refs_store, &referral);
        sctx->refs++;
        sctx->refs_store[sctx->refs] = NULL;
 
index 76b54ddb8018ff8ef8145d2ea0ed24b1540c9699..2400fef2dc55bc176ba460c194ceb179644da7ef 100644 (file)
@@ -387,7 +387,7 @@ talloc_realloc(ctx, ptr, type, 0)  ==> talloc_free(ptr);</programlisting>
          data if you do this.
         </para>
     </refsect2>
-    <refsect2><title>TYPE *talloc_move(const void *<emphasis role="italic">new_ctx</emphasis>, TYPE *<emphasis role="italic">ptr</emphasis>);</title>
+    <refsect2><title>TYPE *talloc_move(const void *<emphasis role="italic">new_ctx</emphasis>, TYPE **<emphasis role="italic">ptr</emphasis>);</title>
         <para>
          The talloc_move() function is a wrapper around
          talloc_steal() which zeros the source pointer after the
index b9ecd8f0b81c4224df591b95ec3d7f020b5b33c6..56f9dbb21ab4cc9787edbd03bb281b66c112830a 100644 (file)
@@ -73,7 +73,7 @@ typedef void TALLOC_CTX;
 #endif
 
 #define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
-#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_move((ctx),&(ptr))
+#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(const void **)(ptr))
 
 /* useful macros for creating type checked pointers */
 #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
index 38039c11bf4d7827f4f6145ecc0f2544c54c2c3f..00ea212e58f145b6b00ca654422a43bc49b7814b 100644 (file)
@@ -750,8 +750,8 @@ static bool test_move(void)
        t1->x = talloc(t1, int);
        *t1->x = 42;
 
-       t2->p = talloc_move(t2, t1->p);
-       t2->x = talloc_move(t2, t1->x);
+       t2->p = talloc_move(t2, &t1->p);
+       t2->x = talloc_move(t2, &t1->x);
        if (t1->p != NULL || t1->x != NULL ||
            strcmp(t2->p, "foo") ||
            *t2->x != 42) {