From 4b6af34c0693f7784d55665f97f8904d1a012f0d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 21 Jun 2022 22:59:57 -0400 Subject: [PATCH] kernel: Move aligned_alloc to heap.cpp alongside calloc. It is independent of whatever heap implementation is actually in use, so it belongs in here (even if this file is probably not the right place for such functions in the first place.) This allows the kernel to be built once again with things other than the default slab heap. --- src/system/kernel/heap.cpp | 10 ++++++++++ src/system/kernel/slab/allocator.cpp | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp index abd9bbdbd9..7036574cce 100644 --- a/src/system/kernel/heap.cpp +++ b/src/system/kernel/heap.cpp @@ -2493,6 +2493,16 @@ calloc(size_t numElements, size_t size) } +void * +aligned_alloc(size_t alignment, size_t size) +{ + if ((size % alignment) != 0) + return NULL; + + return memalign(alignment, size); +} + + void deferred_free(void *block) { diff --git a/src/system/kernel/slab/allocator.cpp b/src/system/kernel/slab/allocator.cpp index f9f1456076..5141439e42 100644 --- a/src/system/kernel/slab/allocator.cpp +++ b/src/system/kernel/slab/allocator.cpp @@ -229,16 +229,6 @@ posix_memalign(void** _pointer, size_t alignment, size_t size) } -void * -aligned_alloc(size_t alignment, size_t size) -{ - if ((size % alignment) != 0) - return NULL; - - return memalign(alignment, size); -} - - void free_etc(void *address, uint32 flags) {