summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-13 02:33:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:18:29 -0500
commit05cdd9ccafeeb384792b9ce7ca044bcec1bfc839 (patch)
tree5e34e06ecfa90d4248e4d511af80f67636c759ac /source4/lib
parent24fe49a3d10633fa9be5547e89d10be1d5f9ccb1 (diff)
downloadsamba-05cdd9ccafeeb384792b9ce7ca044bcec1bfc839.tar.gz
samba-05cdd9ccafeeb384792b9ce7ca044bcec1bfc839.tar.bz2
samba-05cdd9ccafeeb384792b9ce7ca044bcec1bfc839.zip
r18439: 2nd try at a talloc_move() api. This type with the ** ptr interface
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)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb.c4
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c7
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c8
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c2
-rw-r--r--source4/lib/ldb/modules/asq.c4
-rw-r--r--source4/lib/ldb/modules/objectclass.c2
-rw-r--r--source4/lib/ldb/modules/paged_results.c4
-rw-r--r--source4/lib/ldb/modules/sort.c12
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c9
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c4
-rw-r--r--source4/lib/talloc/talloc.3.xml2
-rw-r--r--source4/lib/talloc/talloc.h2
-rw-r--r--source4/lib/talloc/testsuite.c4
14 files changed, 34 insertions, 32 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 1089fb3d92..473c6324ed 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -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;
}
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 49a8e8627a..5b69ac06c9 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -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;
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 9d71b9e8e8..91256222b1 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -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");
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index f2816ec1da..59c1645ba8 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -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) {
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 612ca5c0fe..7cdb2b672f 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -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)++;
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index 75afae2c7e..229a6eacd9 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -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);
}
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c
index fb7cd5db5e..493ecdaad4 100644
--- a/source4/lib/ldb/modules/objectclass.c
+++ b/source4/lib/ldb/modules/objectclass.c
@@ -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);
}
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index 6636efcccb..133ee1fb78 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -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;
}
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index acee40833b..3a0598c528 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -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) {
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index dae3778d82..23cf892930 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -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;
}
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index 181d857efc..23d8115c20 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -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;
diff --git a/source4/lib/talloc/talloc.3.xml b/source4/lib/talloc/talloc.3.xml
index 76b54ddb80..2400fef2dc 100644
--- a/source4/lib/talloc/talloc.3.xml
+++ b/source4/lib/talloc/talloc.3.xml
@@ -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
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h
index b9ecd8f0b8..56f9dbb21a 100644
--- a/source4/lib/talloc/talloc.h
+++ b/source4/lib/talloc/talloc.h
@@ -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)
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c
index 38039c11bf..00ea212e58 100644
--- a/source4/lib/talloc/testsuite.c
+++ b/source4/lib/talloc/testsuite.c
@@ -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) {