diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-03-31 16:51:40 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-04-08 09:28:10 +0200 |
commit | 13fab67995a0b836b92847536768703dac391b57 (patch) | |
tree | cbc79bfd2adadc7b355193937f4155b4281b8c01 /lib/talloc | |
parent | 4084cb723c4e14898a411fbd1cf8fa878ff290ff (diff) | |
download | samba-13fab67995a0b836b92847536768703dac391b57.tar.gz samba-13fab67995a0b836b92847536768703dac391b57.tar.bz2 samba-13fab67995a0b836b92847536768703dac391b57.zip |
talloc: add TC_POOL_SPACE_LEFT() macro
metze
Signed-off-By: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'lib/talloc')
-rw-r--r-- | lib/talloc/talloc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 867705fdf4..8caa6837bb 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -333,6 +333,10 @@ _PUBLIC_ const char *talloc_parent_name(const void *ptr) #define TALLOC_POOL_HDR_SIZE 16 +#define TC_POOL_SPACE_LEFT(_pool_tc) \ + PTR_DIFF(TC_HDR_SIZE + (_pool_tc)->size + (char *)(_pool_tc), \ + (_pool_tc)->pool) + static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc) { return (unsigned int *)((char *)tc + TC_HDR_SIZE); @@ -365,8 +369,7 @@ static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent, return NULL; } - space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size) - - ((char *)pool_ctx->pool); + space_left = TC_POOL_SPACE_LEFT(pool_ctx); /* * Align size to 16 bytes |