diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-11-19 23:30:55 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | f5ef1937eafb3d96b3683d92639a193694210c70 (patch) | |
tree | 0edcffc7447c42fe8467e2b788ee8f65f96b7fe2 /asl/allocator.cpp | |
parent | 3bddc19f5854857788330f11993336f645c414ab (diff) |
More work on asl::box
Diffstat (limited to 'asl/allocator.cpp')
-rw-r--r-- | asl/allocator.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
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<size_t>(new_layout.size),
+ static_cast<size_t>(new_layout.align));
+#elif ASL_OS_LINUX
if (new_layout.align <= old_layout.align)
{
void* new_ptr = ::realloc(old_ptr, static_cast<size_t>(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
}
|