summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-08-27 12:54:38 -0700
committerKarolin Seeger <kseeger@samba.org>2015-03-15 22:14:07 +0100
commite17b67063bfe4ff8ba76b0308016d1e3c4ad8eb9 (patch)
treebf2800f279e112db72c6feeb0702bb8de4099e8c
parent0aa59adbf33b77be35f85afad2fca043c2eab8be (diff)
downloadsamba-e17b67063bfe4ff8ba76b0308016d1e3c4ad8eb9.tar.gz
Inside _talloc_free_internal(), always call talloc_memlimit_update_on_free() before we free the real memory.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Simo Sorce <idra@samba.org> (cherry picked from commit 6bc190d6dd7fd0ab028c39c1463477a863f6943a)
-rw-r--r--lib/talloc/talloc.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index c45ac9327bc..74eca3f5e65 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -909,29 +909,6 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
tc->flags |= TALLOC_FLAG_FREE;
- /*
- * If we are part of a memory limited context hierarchy
- * we need to subtract the memory used from the counters
- */
- if (tc->limit) {
- struct talloc_memlimit *l;
-
- for (l = tc->limit; l != NULL; l = l->upper) {
- if (l->cur_size >= tc->size+TC_HDR_SIZE) {
- l->cur_size -= tc->size+TC_HDR_SIZE;
- } else {
- talloc_abort("cur_size memlimit counter not correct!");
- return 0;
- }
- }
-
- if (tc->limit->parent == tc) {
- free(tc->limit);
- }
-
- tc->limit = NULL;
- }
-
/* we mark the freed memory with where we called the free
* from. This means on a double free error we can report where
* the first free came from
@@ -952,6 +929,8 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
return 0;
}
+ talloc_memlimit_update_on_free(tc);
+
TC_INVALIDATE_FULL_CHUNK(tc);
free(tc);
return 0;
@@ -962,6 +941,8 @@ static inline int _talloc_free_internal(void *ptr, const char *location)
return 0;
}
+ talloc_memlimit_update_on_free(tc);
+
TC_INVALIDATE_FULL_CHUNK(tc);
free(tc);
return 0;