svn commit: samba r16723 - in branches/tmp/vl-messaging/source/lib: .

ab at samba.org ab at samba.org
Sat Jul 1 07:38:27 GMT 2006


Author: ab
Date: 2006-07-01 07:38:26 +0000 (Sat, 01 Jul 2006)
New Revision: 16723

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

Log:
Remove talloc_steal() usage from vl-messaging code before merging with the trunk. Patch from Aleksey Fedoseev
Modified:
   branches/tmp/vl-messaging/source/lib/dbwrap_file.c
   branches/tmp/vl-messaging/source/lib/dbwrap_msg.c


Changeset:
Modified: branches/tmp/vl-messaging/source/lib/dbwrap_file.c
===================================================================
--- branches/tmp/vl-messaging/source/lib/dbwrap_file.c	2006-07-01 02:15:52 UTC (rev 16722)
+++ branches/tmp/vl-messaging/source/lib/dbwrap_file.c	2006-07-01 07:38:26 UTC (rev 16723)
@@ -314,7 +314,13 @@
 			}
 
 			data.dsize = rec->value.dsize;
-			data.dptr = talloc_steal(mem_ctx, rec->value.dptr);
+			data.dptr = talloc_memdup(mem_ctx, rec->value.dptr, rec->value.dsize);
+			if(data.dptr == NULL) {
+				DEBUG(0, ("talloc failed\n"));
+				TALLOC_FREE(rec);
+				TALLOC_FREE(mem_ctx);
+				return -1;				
+			}
 			TALLOC_FREE(rec);
 			count += 1;
 

Modified: branches/tmp/vl-messaging/source/lib/dbwrap_msg.c
===================================================================
--- branches/tmp/vl-messaging/source/lib/dbwrap_msg.c	2006-07-01 02:15:52 UTC (rev 16722)
+++ branches/tmp/vl-messaging/source/lib/dbwrap_msg.c	2006-07-01 07:38:26 UTC (rev 16723)
@@ -310,27 +310,42 @@
 
 	wait_for_return(ctx);
 
-	if(ctx->record) {
-		ctx->record->key.dsize = key.dsize;
-		ctx->record->key.dptr = talloc_memdup(ctx->record, key.dptr, key.dsize);
-		if(ctx->record->key.dptr == NULL) {
-			DEBUG(0, ("talloc failed\n"));
-			TALLOC_FREE(ctx->record);
-			return NULL;
-		}
-	} else {
+	if(!ctx->record) {
 		DEBUG(0, ("db record is NULL\n"));
 		return NULL;
 	}
-	
-	result = talloc_steal(mem_ctx, ctx->record);
+
+	result = TALLOC_P(mem_ctx, struct db_record);
 	if(result == NULL) {
-		DEBUG(0, ("talloc_steal failed\n"));
+		DEBUG(0, ("talloc failed\n"));
 		TALLOC_FREE(ctx->record);
 		return NULL;
 	}
+
+	result->key.dsize = key.dsize;
+	result->key.dptr = talloc_memdup(result, key.dptr, key.dsize);
+	if(result->key.dptr == NULL) {
+		DEBUG(0, ("talloc failed\n"));
+		TALLOC_FREE(ctx->record);
+		TALLOC_FREE(result);
+		return NULL;
+	}
+
+	result->value.dsize = ctx->record->value.dsize;
+	result->value.dptr = talloc_memdup(result, ctx->record->value.dptr,
+									 ctx->record->value.dsize);
+	if(result->value.dptr == NULL) {
+		DEBUG(0, ("talloc failed\n"));
+		TALLOC_FREE(ctx->record);
+		TALLOC_FREE(result);
+		return NULL;
+	}
+
+	result->store = db_msg_store;
+	result->delete_rec = db_msg_delete;
+	result->private_data = ctx;
 	
-	ctx->record = NULL;
+	TALLOC_FREE(ctx->record);
 
 	return result;
 }
@@ -467,13 +482,14 @@
 
 	if(value.dsize > 0) {
 		result->value.dsize = value.dsize;
-		result->value.dptr = talloc_steal(result, value.dptr);
+		result->value.dptr = talloc_memdup(result, value.dptr, value.dsize);
 		if (result->value.dptr == NULL) {
-			DEBUG(0, ("talloc_steal failed\n"));
+			DEBUG(0, ("talloc failed\n"));
 			TALLOC_FREE(value.dptr);
 			TALLOC_FREE(result);
 			return ;
 		}
+		TALLOC_FREE(value.dptr);
 	}
 	result->store = db_msg_store;
 	result->delete_rec = db_msg_delete;



More information about the samba-cvs mailing list