From e78bfc960385a094b03faa462408d8c8391fcbaf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 29 Oct 2004 11:39:08 +0000 Subject: r3366: updates from the junkcode version of talloc. The main change is to get rid of talloc_parent_chunk() from all commonly used code paths, so talloc_free() is now O(1) again. It was originally O(1), but the last round of changes broke that. Also some documentation updates (This used to be commit d4fe21cdb982c8046b19f671d872b43cdd2efc72) --- source4/lib/talloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c index 12b21d21e6..131edfcb81 100644 --- a/source4/lib/talloc.c +++ b/source4/lib/talloc.c @@ -441,7 +441,7 @@ int talloc_free(void *ptr) if (tc->refs) { talloc_reference_destructor(tc->refs); - return 0; + return -1; } if (tc->destructor) { @@ -469,11 +469,13 @@ int talloc_free(void *ptr) struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); if (p) new_parent = p+1; } - if (new_parent == null_context) { - struct talloc_chunk *p = talloc_parent_chunk(ptr); - if (p) new_parent = p+1; + if (talloc_free(child) == -1) { + if (new_parent == null_context) { + struct talloc_chunk *p = talloc_parent_chunk(ptr); + if (p) new_parent = p+1; + } + talloc_steal(new_parent, child); } - talloc_free(talloc_steal(new_parent, child)); } if (tc->parent) { -- cgit