svn commit: samba r3656 - in branches/SAMBA_4_0/source/lib: .

tridge at samba.org tridge at samba.org
Wed Nov 10 11:00:13 GMT 2004


Author: tridge
Date: 2004-11-10 11:00:13 +0000 (Wed, 10 Nov 2004)
New Revision: 3656

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

Log:
allow easy testing of the "realloc changes the pointer" type of problem that abartlet 
recently fixed. 

Modified:
   branches/SAMBA_4_0/source/lib/talloc.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc.c	2004-11-10 10:58:15 UTC (rev 3655)
+++ branches/SAMBA_4_0/source/lib/talloc.c	2004-11-10 11:00:13 UTC (rev 3656)
@@ -40,6 +40,11 @@
 #include "includes.h"
 #endif
 
+/* use this to force every realloc to change the pointer, to stress test
+   code that might not cope */
+#define ALWAYS_REALLOC 0
+
+
 #define MAX_TALLOC_SIZE 0x10000000
 #define TALLOC_MAGIC 0xe814ec4f
 #define TALLOC_MAGIC_FREE 0x7faebef3
@@ -538,7 +543,15 @@
 	/* by resetting magic we catch users of the old memory */
 	tc->magic = TALLOC_MAGIC_FREE;
 
+#if ALWAYS_REALLOC
+	new_ptr = malloc(size + sizeof(*tc));
+	if (new_ptr) {
+		memcpy(new_ptr, tc, tc->size + sizeof(*tc));
+		free(tc);
+	}
+#else
 	new_ptr = realloc(tc, size + sizeof(*tc));
+#endif
 	if (!new_ptr) {	
 		tc->magic = TALLOC_MAGIC; 
 		return NULL; 



More information about the samba-cvs mailing list