From 1901ff9942837e9cad22269b16b33a6af3df92a9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:12:07 +0000 Subject: [PATCH] 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 --- lib/talloc/talloc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 33cbfd7d268d..1a316d6d58de 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; } -- 2.34.1