mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
LibC: static_assert that all malloc size classes have an alignment of 8
This will help prevent issues like the one fixed by #6703 from happening again.
This commit is contained in:
parent
ae5ee2220c
commit
edfe81b1ee
1 changed files with 10 additions and 0 deletions
|
@ -17,6 +17,16 @@
|
|||
static constexpr unsigned short size_classes[] = { 8, 16, 32, 64, 128, 256, 504, 1016, 2032, 4088, 8184, 16376, 32752, 0 };
|
||||
static constexpr size_t num_size_classes = (sizeof(size_classes) / sizeof(unsigned short)) - 1;
|
||||
|
||||
consteval bool check_size_classes_alignment()
|
||||
{
|
||||
for (size_t i = 0; i < num_size_classes; i++) {
|
||||
if ((size_classes[i] % 8) != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static_assert(check_size_classes_alignment());
|
||||
|
||||
struct CommonHeader {
|
||||
size_t m_magic;
|
||||
size_t m_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue