From e75542f6f2e745dd64c106ad7167b37cfd16c5f5 Mon Sep 17 00:00:00 2001 From: Mineplay Date: Sat, 19 Apr 2025 09:22:51 -0500 Subject: [PATCH] fix(allocator): fixed allocator for windows --- Include/Hallocy/Core/Allocator.h | 8 ++++---- Src/Core/Allocator.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Include/Hallocy/Core/Allocator.h b/Include/Hallocy/Core/Allocator.h index 85c0111..3699476 100644 --- a/Include/Hallocy/Core/Allocator.h +++ b/Include/Hallocy/Core/Allocator.h @@ -28,11 +28,11 @@ #include "../Utils/Error.h" -void *hallocy_allocate(size_t size, bool zero_memory); +void *hallocy_allocate(const size_t size, const bool zero_memory); -static inline void *hallocy_malloc(size_t size) { return hallocy_allocate(size, false); } -static inline void *hallocy_calloc(size_t size, size_t count) { return hallocy_allocate(size * count, true); } -void *hallocy_realloc(void *memory_pointer, size_t size); +static inline void *hallocy_malloc(const size_t size) { return hallocy_allocate(size, false); } +static inline void *hallocy_calloc(const size_t size, size_t count) { return hallocy_allocate(size * count, true); } +void *hallocy_realloc(void *memory_pointer, const size_t size); HallocyError hallocy_free(void *pointer); #endif \ No newline at end of file diff --git a/Src/Core/Allocator.c b/Src/Core/Allocator.c index 96ee44f..d703421 100644 --- a/Src/Core/Allocator.c +++ b/Src/Core/Allocator.c @@ -26,7 +26,7 @@ #if defined(_WIN32) #include -static const INIT_ONCE HALLOCY_INIT_ONCE = INIT_ONCE_STATIC_INIT; +static INIT_ONCE HALLOCY_INIT_ONCE = INIT_ONCE_STATIC_INIT; static HANDLE hallocy_heap = NULL; static CRITICAL_SECTION hallocy_critical_section; @@ -69,7 +69,7 @@ static BOOL CALLBACK hallocy_initialize_mutex(PINIT_ONCE init_once, PVOID parame } #endif -void *hallocy_allocate(size_t size, bool zero_memory) { +void *hallocy_allocate(const size_t size, const bool zero_memory) { if (page_size == 0) { #if defined(_WIN32) SYSTEM_INFO system_info; @@ -229,7 +229,7 @@ void *hallocy_allocate(size_t size, bool zero_memory) { return (void*)(memory_pointer + 1); } -void *hallocy_realloc(void *memory_pointer, size_t size) { +void *hallocy_realloc(void *memory_pointer, const size_t size) { if (memory_pointer == NULL) { return hallocy_allocate(size, false); }