From: Jeremy Allison Date: Tue, 27 Aug 2013 19:46:09 +0000 (-0700) Subject: Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calcu... X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=33d24f26485721190f20d7e1ec759107dc9c9340 Change _talloc_total_mem_internal() to ignore memory allocated from a pool when calculating limit size. We must only count normal tallocs, or a talloc pool itself. Signed-off-by: Jeremy Allison Reviewed-by: Simo Sorce (cherry picked from commit 4159a78ed7eda340758e22286f16186987a20f2f) --- diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 7b827ca0c15c..1e25dfde4e1e 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -1817,7 +1817,14 @@ static size_t _talloc_total_mem_internal(const void *ptr, break; case TOTAL_MEM_LIMIT: if (likely(tc->name != TALLOC_MAGIC_REFERENCE)) { - total = tc->size + TC_HDR_SIZE; + /* + * Don't count memory allocated from a pool + * when calculating limits. Only count the + * pool itself. + */ + if (!(tc->flags & TALLOC_FLAG_POOLMEM)) { + total = tc->size + TC_HDR_SIZE; + } } break; }