X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fralloc.c;h=7bf192e0db7816f3d84222b2d20ff56c398dfefd;hb=837ad2dc384096d936fd65e30374129f36e09335;hp=980e4e4f138b5dbd57a7394da84257819b830e36;hpb=6608dbf540c3724f8cc20619ef3ffb23257dc721;p=mesa.git diff --git a/src/util/ralloc.c b/src/util/ralloc.c index 980e4e4f138..7bf192e0db7 100644 --- a/src/util/ralloc.c +++ b/src/util/ralloc.c @@ -51,7 +51,20 @@ _CRTIMP int _vscprintf(const char *format, va_list argptr); #define CANARY 0x5A1106 -struct ralloc_header +/* Align the header's size so that ralloc() allocations will return with the + * same alignment as a libc malloc would have (8 on 32-bit GLIBC, 16 on + * 64-bit), avoiding performance penalities on x86 and alignment faults on + * ARM. + */ +struct +#ifdef _MSC_VER + __declspec(align(8)) +#elif defined(__LP64__) + __attribute__((aligned(16))) +#else + __attribute__((aligned(8))) +#endif + ralloc_header { #ifdef DEBUG /* A canary value used to determine whether a pointer is ralloc'd. */ @@ -323,24 +336,6 @@ ralloc_parent(const void *ptr) return info->parent ? PTR_FROM_HEADER(info->parent) : NULL; } -static void *autofree_context = NULL; - -static void -autofree(void) -{ - ralloc_free(autofree_context); -} - -void * -ralloc_autofree_context(void) -{ - if (unlikely(autofree_context == NULL)) { - autofree_context = ralloc_context(NULL); - atexit(autofree); - } - return autofree_context; -} - void ralloc_set_destructor(const void *ptr, void(*destructor)(void *)) {