diff options
author | Jeremy Allison <jra@samba.org> | 2001-02-27 19:22:02 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-02-27 19:22:02 +0000 |
commit | 5265ce7837a185977f71bcb39a41b57492e24964 (patch) | |
tree | bc5f6b359d30f74f156af64de8253c2e8d311343 /source3/lib | |
parent | dbc5cace14de14556da7a32cd9f4a82ef522e401 (diff) | |
download | samba-5265ce7837a185977f71bcb39a41b57492e24964.tar.gz samba-5265ce7837a185977f71bcb39a41b57492e24964.tar.bz2 samba-5265ce7837a185977f71bcb39a41b57492e24964.zip |
Added total memory allocated counter to talloc, so we can tell if a talloc
pool is getting bloated. Also added a talloc_zero function to return zeroed memory.
Added debug in rpc_server/srv_pipe_hnd.c so we know when a talloc pool is being
freed. Syncup with srv_pipe_hnd.c from 2.2 so we are freeing memory at the same time.
Jeremy.
(This used to be commit d3a56c6042acf037bbd53de88d7636a5803ead20)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/talloc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index a04bd2561b..854a230a0e 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -47,6 +47,7 @@ TALLOC_CTX *talloc_init(void) if (!t) return NULL; t->list = NULL; + t->total_alloc_size = 0; return t; } @@ -82,6 +83,7 @@ void *talloc(TALLOC_CTX *t, size_t size) c->alloc_size = 0; c->total_size = asize; t->list = c; + t->total_alloc_size += asize; } p = ((char *)t->list->ptr) + t->list->alloc_size; @@ -107,6 +109,7 @@ void talloc_destroy_pool(TALLOC_CTX *t) } t->list = NULL; + t->total_alloc_size = 0; } /* destroy a whole pool including the context */ @@ -117,3 +120,22 @@ void talloc_destroy(TALLOC_CTX *t) talloc_destroy_pool(t); free(t); } + +/* return the current total size of the pool. */ +size_t talloc_pool_size(TALLOC_CTX *t) +{ + if (!t->list) + return 0; + return t->total_alloc_size; +} + +/* talloc and zero memory. */ +void *talloc_zero(TALLOC_CTX *t, size_t size) +{ + void *p = talloc(t, size); + + if (p) + memset(p, '\0', size); + + return p; +} |