fix(allocator): fixed allocator for windows

This commit is contained in:
Mineplay 2025-04-19 09:22:51 -05:00
parent 0c7fa8cec0
commit e75542f6f2
2 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -26,7 +26,7 @@
#if defined(_WIN32)
#include <windows.h>
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);
}