svn commit: samba r18439 - in branches/SAMBA_4_0/source/lib: ldb/common ldb/ldb_ildap ldb/ldb_sqlite3 ldb/ldb_tdb ldb/modules ldb/tools talloc

tridge at samba.org tridge at samba.org
Wed Sep 13 02:33:51 GMT 2006


Author: tridge
Date: 2006-09-13 02:33:51 +0000 (Wed, 13 Sep 2006)
New Revision: 18439

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18439

Log:

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.

Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
   branches/SAMBA_4_0/source/lib/ldb/modules/asq.c
   branches/SAMBA_4_0/source/lib/ldb/modules/objectclass.c
   branches/SAMBA_4_0/source/lib/ldb/modules/paged_results.c
   branches/SAMBA_4_0/source/lib/ldb/modules/sort.c
   branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c
   branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c
   branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml
   branches/SAMBA_4_0/source/lib/talloc/talloc.h
   branches/SAMBA_4_0/source/lib/talloc/testsuite.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -528,7 +528,7 @@
 
 		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 @@
 			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;
 	}
 

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -249,7 +249,7 @@
 					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 @@
 					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 @@
 
 	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;

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -865,7 +865,7 @@
 
 		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");

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -378,7 +378,7 @@
 	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 @@
 	}
 
 	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 @@
 
 		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 @@
 		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) {

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_search.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -312,7 +312,7 @@
 
 	(*res) = res2;
 
-	(*res)[*count] = talloc_move(*res, msg2);
+	(*res)[*count] = talloc_move(*res, &msg2);
 	(*res)[(*count)+1] = NULL;
 	(*count)++;
 

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/asq.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/asq.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/asq.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -117,7 +117,7 @@
 
 	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 @@
 
 	/* 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);
 	}

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/objectclass.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/objectclass.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/objectclass.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -439,7 +439,7 @@
 			return LDB_ERR_OPERATIONS_ERROR;
 		}
 
-		ac->search_res = talloc_move(ac, ares);
+		ac->search_res = talloc_move(ac, &ares);
 	} else {
 		talloc_free(ares);
 	}

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/paged_results.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/paged_results.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/paged_results.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -210,7 +210,7 @@
 	}
 
 	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 @@
 		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;
 	}
 

Modified: branches/SAMBA_4_0/source/lib/ldb/modules/sort.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/sort.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/sort.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -185,7 +185,7 @@
 
 		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 @@
 		}
 
 		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 @@
 		}
 
 		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 @@
 		}
 
 		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 @@
 	}
 
 	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) {

Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -139,7 +139,8 @@
 		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 @@
 		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 @@
 			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 @@
 		} 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;
 		}

Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -81,7 +81,7 @@
 		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 @@
 		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;
 

Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.3.xml	2006-09-13 02:33:51 UTC (rev 18439)
@@ -387,7 +387,7 @@
 	  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

Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.h	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.h	2006-09-13 02:33:51 UTC (rev 18439)
@@ -73,7 +73,7 @@
 #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)

Modified: branches/SAMBA_4_0/source/lib/talloc/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/testsuite.c	2006-09-13 02:03:20 UTC (rev 18438)
+++ branches/SAMBA_4_0/source/lib/talloc/testsuite.c	2006-09-13 02:33:51 UTC (rev 18439)
@@ -750,8 +750,8 @@
 	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) {



More information about the samba-cvs mailing list