diff options
author | Jeremy Allison <jra@samba.org> | 2013-08-27 12:57:43 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-08-27 15:44:19 -0700 |
commit | 43860293225d14ca2c339277b42f8705322463ab (patch) | |
tree | f9018cdfde4b22fac6a700c60519460f2756f8f0 /lib | |
parent | 6bc190d6dd7fd0ab028c39c1463477a863f6943a (diff) | |
download | samba-43860293225d14ca2c339277b42f8705322463ab.tar.gz samba-43860293225d14ca2c339277b42f8705322463ab.tar.bz2 samba-43860293225d14ca2c339277b42f8705322463ab.zip |
In _talloc_steal_internal(), correctly decrement the memory limit in the source, and increment in the destination.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/talloc/talloc.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 74eca3f5e6..54f3c0a56d 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -976,11 +976,8 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr) ctx_size = _talloc_total_limit_size(ptr, NULL, NULL); - if (!talloc_memlimit_update(tc->limit->upper, ctx_size, 0)) { - talloc_abort("cur_size memlimit counter not correct!"); - errno = EINVAL; - return NULL; - } + /* Decrement the memory limit from the source .. */ + talloc_memlimit_shrink(tc->limit->upper, ctx_size); if (tc->limit->parent == tc) { tc->limit->upper = NULL; @@ -1028,13 +1025,9 @@ static void *_talloc_steal_internal(const void *new_ctx, const void *ptr) if (tc->limit || new_tc->limit) { ctx_size = _talloc_total_limit_size(ptr, tc->limit, new_tc->limit); - } - - if (new_tc->limit) { - struct talloc_memlimit *l; - - for (l = new_tc->limit; l != NULL; l = l->upper) { - l->cur_size += ctx_size; + /* .. and increment it in the destination. */ + if (new_tc->limit) { + talloc_memlimit_grow(new_tc->limit, ctx_size); } } |