1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

Kernel: Start implementing kmalloc_aligned more efficiently

This now only requires `size + alignment` bytes while searching for a
free memory location. For the actual allocation, the memory area is
properly trimmed to the required alignment.
This commit is contained in:
Tim Schumacher 2022-12-07 05:02:59 +01:00 committed by Linus Groh
parent 30a553ef80
commit 2577bb8416
3 changed files with 37 additions and 35 deletions

View file

@ -27,7 +27,7 @@ public: \
} \
void operator delete(void* ptr) noexcept \
{ \
kfree_aligned(ptr); \
kfree_sized(ptr, sizeof(type)); \
} \
\
private:
@ -82,13 +82,6 @@ void operator delete[](void* ptr, size_t) noexcept;
[[gnu::malloc, gnu::alloc_size(1), gnu::alloc_align(2)]] void* kmalloc_aligned(size_t size, size_t alignment);
inline void kfree_aligned(void* ptr)
{
if (ptr == nullptr)
return;
kfree_sized((u8*)ptr - ((ptrdiff_t const*)ptr)[-1], ((size_t const*)ptr)[-2]);
}
size_t kmalloc_good_size(size_t);
void kmalloc_enable_expand();