Skip to content

Commit

Permalink
LibC: Increase alignment for malloc() BigAllocationBlocks to 16 bytes
Browse files Browse the repository at this point in the history
commit 5f3773b increased alignment
for ChunckedBlocks, but not for BigAllocationBlocks.

This is required to make SSE instructions work.
  • Loading branch information
rouseabout authored and awesomekling committed Mar 2, 2022
1 parent 36af2fd commit feb1964
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibC/malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibC/mallocdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit feb1964

Please sign in to comment.