diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-09-29 10:53:27 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:14:54 -0500 |
commit | 43be47f56bcaa2fd93ede867663cddec04fd8fed (patch) | |
tree | 2032aee6a9f03c1efaefbf7fdda14b6e20c8ce2f /source3/lib/talloc/talloc.c | |
parent | da6c811eca4b03395bc76a34eaeaedf5566154ba (diff) | |
download | samba-43be47f56bcaa2fd93ede867663cddec04fd8fed.tar.gz samba-43be47f56bcaa2fd93ede867663cddec04fd8fed.tar.bz2 samba-43be47f56bcaa2fd93ede867663cddec04fd8fed.zip |
r18996: merge from samba4:
- fix bug 4078
- talloc_free(talloc_autofree_context()); should not result
in a SIGABORT on exit
- add a test for this, but this test can also pass in the standalone build
and samba3, as samba4 uses talloc_autofree_context()
metze
(This used to be commit f5b0924f975f58bba3c13a53388ea25af51d3bc8)
Diffstat (limited to 'source3/lib/talloc/talloc.c')
-rw-r--r-- | source3/lib/talloc/talloc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/lib/talloc/talloc.c b/source3/lib/talloc/talloc.c index 58028a85b8..15b27c61ee 100644 --- a/source3/lib/talloc/talloc.c +++ b/source3/lib/talloc/talloc.c @@ -82,7 +82,7 @@ NULL */ static void *null_context; -static void *cleanup_context; +static void *autofree_context; struct talloc_reference_handle { struct talloc_reference_handle *next, *prev; @@ -1208,10 +1208,15 @@ void *talloc_realloc_fn(const void *context, void *ptr, size_t size) } +static int talloc_autofree_destructor(void *ptr) +{ + autofree_context = NULL; + return 0; +} + static void talloc_autofree(void) { - talloc_free(cleanup_context); - cleanup_context = NULL; + talloc_free(autofree_context); } /* @@ -1220,11 +1225,12 @@ static void talloc_autofree(void) */ void *talloc_autofree_context(void) { - if (cleanup_context == NULL) { - cleanup_context = talloc_named_const(NULL, 0, "autofree_context"); + if (autofree_context == NULL) { + autofree_context = talloc_named_const(NULL, 0, "autofree_context"); + talloc_set_destructor(autofree_context, talloc_autofree_destructor); atexit(talloc_autofree); } - return cleanup_context; + return autofree_context; } size_t talloc_get_size(const void *context) |