mesa/main: Maintain compressed TexEnv Combine state.
[mesa.git] / src / util / ralloc.c
index 980e4e4f138b5dbd57a7394da84257819b830e36..7bf192e0db7816f3d84222b2d20ff56c398dfefd 100644 (file)
@@ -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 *))
 {