From f5ef1937eafb3d96b3683d92639a193694210c70 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Tue, 19 Nov 2024 23:30:55 +0100 Subject: More work on asl::box --- asl/allocator.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'asl/allocator.cpp') diff --git a/asl/allocator.cpp b/asl/allocator.cpp index f50b42b..8fbca4e 100644 --- a/asl/allocator.cpp +++ b/asl/allocator.cpp @@ -26,6 +26,11 @@ void* asl::GlobalHeap::alloc(const layout& layout) void* asl::GlobalHeap::realloc(void* old_ptr, const layout& old_layout, const layout& new_layout) { +#if ASL_OS_WINDOWS + return ::_aligned_realloc(old_ptr, + static_cast(new_layout.size), + static_cast(new_layout.align)); +#elif ASL_OS_LINUX if (new_layout.align <= old_layout.align) { void* new_ptr = ::realloc(old_ptr, static_cast(new_layout.size)); @@ -36,9 +41,14 @@ void* asl::GlobalHeap::realloc(void* old_ptr, const layout& old_layout, const la void* new_ptr = alloc(new_layout); asl::memcpy(new_ptr, old_ptr, asl::min(old_layout.size, new_layout.size)); return new_ptr; +#endif } void asl::GlobalHeap::dealloc(void* ptr, const layout&) { +#if ASL_OS_WINDOWS + ::_aligned_free(ptr); +#elif ASL_OS_LINUX ::free(ptr); +#endif } -- cgit