From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:12:07 +0000 (+0000) Subject: TODO: talloc: talloc_free() should remove the reference to the current owner X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwip.git;a=commitdiff_plain;h=5e4ee76e29add15cde392d74a8fdf074aa7ca6d4 TODO: talloc: talloc_free() should remove the reference to the current owner TODO: talloc: talloc_free() should remove the reference to the current owner The parent of the first reference becomes the owner... metze Signed-off-by: Sam Liddicott --- diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index a1b158a42cd1..d5b0c3bfe532 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -510,9 +510,13 @@ static inline int _talloc_free(void *ptr) * pointer. */ is_child = talloc_is_parent(tc->refs, ptr); - _talloc_free(tc->refs); if (is_child) { + _talloc_free(tc->refs); return _talloc_free(ptr); + } else { + /* the first reference becomes the owner */ + _talloc_steal(talloc_parent(tc->refs), ptr); + _talloc_free(tc->refs); } return -1; }