diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-05-17 07:10:45 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:56 -0500 |
commit | a54f0ea83e3cab4c27e730981bbfec2a958d4829 (patch) | |
tree | e6ca8d0279d792c756048837a2e44672a66f0876 /source3/lib | |
parent | 8a1756006a1abf8ceb22fff889c94b3d28d19c20 (diff) | |
download | samba-a54f0ea83e3cab4c27e730981bbfec2a958d4829.tar.gz samba-a54f0ea83e3cab4c27e730981bbfec2a958d4829.tar.bz2 samba-a54f0ea83e3cab4c27e730981bbfec2a958d4829.zip |
r6849: Merge revision 6845 from Samba 4
(This used to be commit 44365075d22d395992b167e5a04d7083c05878cc)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/talloc.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c index 46abd89bac..15b0f4ea7d 100644 --- a/source3/lib/talloc.c +++ b/source3/lib/talloc.c @@ -94,17 +94,20 @@ struct talloc_chunk { struct talloc_chunk *parent, *child; struct talloc_reference_handle *refs; size_t size; - unsigned magic; talloc_destructor_t destructor; const char *name; + union { + unsigned magic; + double align_dummy; + } u; }; /* panic if we get a bad magic value */ static struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) { struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, ptr)-1; - if (tc->magic != TALLOC_MAGIC) { - if (tc->magic == TALLOC_MAGIC_FREE) { + if (tc->u.magic != TALLOC_MAGIC) { + if (tc->u.magic == TALLOC_MAGIC_FREE) { TALLOC_ABORT("Bad talloc magic value - double free"); } else { TALLOC_ABORT("Bad talloc magic value - unknown value"); @@ -177,7 +180,7 @@ void *_talloc(const void *context, size_t size) if (tc == NULL) return NULL; tc->size = size; - tc->magic = TALLOC_MAGIC; + tc->u.magic = TALLOC_MAGIC; tc->destructor = NULL; tc->child = NULL; tc->name = NULL; @@ -556,7 +559,7 @@ int talloc_free(void *ptr) if (tc->next) tc->next->prev = tc->prev; } - tc->magic = TALLOC_MAGIC_FREE; + tc->u.magic = TALLOC_MAGIC_FREE; free(tc); return 0; @@ -596,7 +599,7 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n } /* by resetting magic we catch users of the old memory */ - tc->magic = TALLOC_MAGIC_FREE; + tc->u.magic = TALLOC_MAGIC_FREE; #if ALWAYS_REALLOC new_ptr = malloc(size + sizeof(*tc)); @@ -608,12 +611,12 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n new_ptr = realloc(tc, size + sizeof(*tc)); #endif if (!new_ptr) { - tc->magic = TALLOC_MAGIC; + tc->u.magic = TALLOC_MAGIC; return NULL; } tc = new_ptr; - tc->magic = TALLOC_MAGIC; + tc->u.magic = TALLOC_MAGIC; if (tc->parent) { tc->parent->child = new_ptr; } |