summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-29 11:39:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:01 -0500
commite78bfc960385a094b03faa462408d8c8391fcbaf (patch)
treec5aee18236ecc694462d4a84bc904e786cba02b1 /source4/lib
parent9a09b41b013e957fb7ce9cd644ac1f6d1fd26528 (diff)
downloadsamba-e78bfc960385a094b03faa462408d8c8391fcbaf.tar.gz
samba-e78bfc960385a094b03faa462408d8c8391fcbaf.tar.bz2
samba-e78bfc960385a094b03faa462408d8c8391fcbaf.zip
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)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/talloc.c12
1 files changed, 7 insertions, 5 deletions
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) {