summaryrefslogtreecommitdiff
path: root/source4/lib/talloc
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-10 11:34:07 +0100
committerMichael Adam <obnox@samba.org>2008-02-11 15:07:46 +0100
commitbdb52e4d58e3e4ce8797050d8e0c2c0ddc1e8e0e (patch)
treede87160eb4d784dc4c4a545e44394d5889f1d49b /source4/lib/talloc
parent7a9033fb2d2057dc8104d9b6f22c94e83e36f8ce (diff)
downloadsamba-bdb52e4d58e3e4ce8797050d8e0c2c0ddc1e8e0e.tar.gz
samba-bdb52e4d58e3e4ce8797050d8e0c2c0ddc1e8e0e.tar.bz2
samba-bdb52e4d58e3e4ce8797050d8e0c2c0ddc1e8e0e.zip
Mark talloc_pool memory for valgrind
(This used to be commit 6deca23b6c66616fbf5ba004e9b778aa68790df6)
Diffstat (limited to 'source4/lib/talloc')
-rw-r--r--source4/lib/talloc/talloc.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index e38a4d6275..9e935b892c 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/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;
}
@@ -859,6 +868,10 @@ void talloc_free_children(void *ptr)
if (tc->flags & TALLOC_FLAG_POOL) {
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
}
}