fix(allocator): fixed allocator for windows
This commit is contained in:
parent
0c7fa8cec0
commit
e75542f6f2
2 changed files with 7 additions and 7 deletions
|
|
@ -28,11 +28,11 @@
|
||||||
|
|
||||||
#include "../Utils/Error.h"
|
#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_malloc(const 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); }
|
static inline void *hallocy_calloc(const size_t size, size_t count) { return hallocy_allocate(size * count, true); }
|
||||||
void *hallocy_realloc(void *memory_pointer, size_t size);
|
void *hallocy_realloc(void *memory_pointer, const size_t size);
|
||||||
HallocyError hallocy_free(void *pointer);
|
HallocyError hallocy_free(void *pointer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#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 HANDLE hallocy_heap = NULL;
|
||||||
static CRITICAL_SECTION hallocy_critical_section;
|
static CRITICAL_SECTION hallocy_critical_section;
|
||||||
|
|
@ -69,7 +69,7 @@ static BOOL CALLBACK hallocy_initialize_mutex(PINIT_ONCE init_once, PVOID parame
|
||||||
}
|
}
|
||||||
#endif
|
#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 (page_size == 0) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
SYSTEM_INFO system_info;
|
SYSTEM_INFO system_info;
|
||||||
|
|
@ -229,7 +229,7 @@ void *hallocy_allocate(size_t size, bool zero_memory) {
|
||||||
return (void*)(memory_pointer + 1);
|
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) {
|
if (memory_pointer == NULL) {
|
||||||
return hallocy_allocate(size, false);
|
return hallocy_allocate(size, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue