فهرست منبع

LibC: Increase alignment for malloc() BigAllocationBlocks to 16 bytes

commit 5f3773b7150cbf113b5a0aabfe2b2670dc758d38 increased alignment
for ChunckedBlocks, but not for BigAllocationBlocks.

This is required to make SSE instructions work.
Peter Ross 3 سال پیش
والد
کامیت
feb19646df
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 1
      Userland/Libraries/LibC/malloc.cpp
  2. 1 1
      Userland/Libraries/LibC/mallocdefs.h

+ 1 - 1
Userland/Libraries/LibC/malloc.cpp

@@ -528,7 +528,7 @@ size_t malloc_size(void const* ptr)
     auto* header = (const CommonHeader*)page_base;
     auto size = header->m_size;
     if (header->m_magic == MAGIC_BIGALLOC_HEADER)
-        size -= sizeof(CommonHeader);
+        size -= sizeof(BigAllocationBlock);
     else
         VERIFY(header->m_magic == MAGIC_PAGE_HEADER);
     return size;

+ 1 - 1
Userland/Libraries/LibC/mallocdefs.h

@@ -46,7 +46,7 @@ struct BigAllocationBlock : public CommonHeader {
         m_magic = MAGIC_BIGALLOC_HEADER;
         m_size = size;
     }
-    unsigned char* m_slot[0];
+    alignas(16) unsigned char* m_slot[0];
 };
 
 struct FreelistEntry {