summaryrefslogtreecommitdiffstats
path: root/lib/talloc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-03-31 16:56:18 +0200
committerStefan Metzmacher <metze@samba.org>2011-04-08 09:28:10 +0200
commit73330f8436707b5ab46c0720ea735908948f5d27 (patch)
tree0f922bf266b936791db390ad7c1b55285ad68ff3 /lib/talloc
parent13fab67995a0b836b92847536768703dac391b57 (diff)
downloadsamba-73330f8436707b5ab46c0720ea735908948f5d27.tar.gz
samba-73330f8436707b5ab46c0720ea735908948f5d27.tar.xz
samba-73330f8436707b5ab46c0720ea735908948f5d27.zip
talloc: add TC_POOL_FIRST_CHUNK() macro
metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'lib/talloc')
-rw-r--r--lib/talloc/talloc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 8caa6837bbc..34a23a3cab2 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -337,6 +337,9 @@ _PUBLIC_ const char *talloc_parent_name(const void *ptr)
PTR_DIFF(TC_HDR_SIZE + (_pool_tc)->size + (char *)(_pool_tc), \
(_pool_tc)->pool)
+#define TC_POOL_FIRST_CHUNK(_pool_tc) \
+ ((void *)(TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE + (char *)(_pool_tc)))
+
static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
{
return (unsigned int *)((char *)tc + TC_HDR_SIZE);
@@ -465,7 +468,7 @@ _PUBLIC_ void *talloc_pool(const void *context, size_t size)
tc = talloc_chunk_from_ptr(result);
tc->flags |= TALLOC_FLAG_POOL;
- tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE;
+ tc->pool = TC_POOL_FIRST_CHUNK(tc);
*talloc_pool_objectcount(tc) = 1;
@@ -1115,7 +1118,7 @@ _PUBLIC_ void talloc_free_children(void *ptr)
if ((tc->flags & TALLOC_FLAG_POOL)
&& (*talloc_pool_objectcount(tc) == 1)) {
- tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
+ tc->pool = TC_POOL_FIRST_CHUNK(tc);
#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
VALGRIND_MAKE_MEM_NOACCESS(
tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);