[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-1246-gee905a0

Volker Lendecke vl at samba.org
Thu Jan 10 11:28:45 GMT 2008


The branch, v3-2-test has been updated
       via  ee905a085fff5410d02c3e5fa2664e989de4afd4 (commit)
       via  0272b46515b4c4515d5cad8e86fab61d8e91e29e (commit)
       via  d89e42f1d2faa018c584025296d6be8195cbcf20 (commit)
      from  af07adaf4293899fcbded666289ffa7479ca0501 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit ee905a085fff5410d02c3e5fa2664e989de4afd4
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 10 11:35:40 2008 +0100

    Fix a c++ warning

commit 0272b46515b4c4515d5cad8e86fab61d8e91e29e
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 10 11:35:17 2008 +0100

    talloc_free_children can only reset pool if it's empty

commit d89e42f1d2faa018c584025296d6be8195cbcf20
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 10 11:34:07 2008 +0100

    Mark talloc_pool memory for valgrind

-----------------------------------------------------------------------

Summary of changes:
 source/lib/talloc/talloc.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/talloc/talloc.c b/source/lib/talloc/talloc.c
index 178bbb9..9dcd8a2 100644
--- a/source/lib/talloc/talloc.c
+++ b/source/lib/talloc/talloc.c
@@ -245,6 +245,7 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 	struct talloc_chunk *pool_ctx = NULL;
 	size_t space_left;
 	struct talloc_chunk *result;
+	size_t chunk_size;
 
 	if (parent == NULL) {
 		return NULL;
@@ -267,15 +268,19 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
 	/*
 	 * Align size to 16 bytes
 	 */
-	size = ((size + 15) & ~15);
+	chunk_size = ((size + 15) & ~15);
 
-	if (space_left < size) {
+	if (space_left < chunk_size) {
 		return NULL;
 	}
 
 	result = (struct talloc_chunk *)pool_ctx->pool;
 
-	pool_ctx->pool = (void *)((char *)result + size);
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
+	VALGRIND_MAKE_MEM_UNDEFINED(result, size);
+#endif
+
+	pool_ctx->pool = (void *)((char *)result + chunk_size);
 
 	result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
 	result->pool = pool_ctx;
@@ -358,6 +363,10 @@ void *talloc_pool(const void *context, size_t size)
 
 	*talloc_pool_objectcount(tc) = 1;
 
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+	VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size);
+#endif
+
 	return result;
 }
 
@@ -857,8 +866,13 @@ void talloc_free_children(void *ptr)
 		}
 	}
 
-	if (tc->flags & TALLOC_FLAG_POOL) {
+	if ((tc->flags & TALLOC_FLAG_POOL)
+	    && (*talloc_pool_objectcount(tc) == 1)) {
 		tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+		VALGRIND_MAKE_MEM_NOACCESS(
+			tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);
+#endif
 	}
 }
 
@@ -954,7 +968,8 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
 	if (tc->flags & TALLOC_FLAG_POOLMEM) {
 
 		new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
-		*talloc_pool_objectcount(tc->pool) -= 1;
+		*talloc_pool_objectcount((struct talloc_chunk *)
+					 (tc->pool)) -= 1;
 
 		if (new_ptr == NULL) {
 			new_ptr = malloc(TC_HDR_SIZE+size);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list