1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-15 16:23:49 +03:00

r18995: - 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 commit is contained in:
Stefan Metzmacher
2006-09-29 10:50:12 +00:00
committed by Gerald (Jerry) Carter
parent 49755f2224
commit 2be48c1b03
2 changed files with 37 additions and 12 deletions

View File

@@ -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)