Skip to content

Commit

Permalink
change macro name
Browse files Browse the repository at this point in the history
  • Loading branch information
YYF233333 committed Nov 20, 2024
1 parent b8f0a74 commit 177b7e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ if env["minizip"]:
if env["brotli"]:
env.Append(CPPDEFINES=["BROTLI_ENABLED"])
if env["mimalloc"]:
env.Append(CPPDEFINES=["MIMALLOC_ENABLED"])
env.Append(CPPDEFINES=["ALLOC_MIMALLOC"])

if not env["verbose"]:
methods.no_verbose(env)
Expand Down
18 changes: 9 additions & 9 deletions core/os/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "core/error/error_macros.h"
#include "core/templates/safe_refcount.h"

#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
#include "thirdparty/mimalloc/include/mimalloc.h"
#endif

Expand Down Expand Up @@ -77,7 +77,7 @@ void *Memory::alloc_aligned_static(size_t p_bytes, size_t p_alignment) {

void *p1, *p2;

#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
if ((p1 = (void *)mi_malloc(p_bytes + p_alignment - 1 + sizeof(uint32_t))) == nullptr) {
#else
if ((p1 = (void *)malloc(p_bytes + p_alignment - 1 + sizeof(uint32_t))) == nullptr) {
Expand All @@ -104,7 +104,7 @@ void *Memory::realloc_aligned_static(void *p_memory, size_t p_bytes, size_t p_pr
void Memory::free_aligned_static(void *p_memory) {
uint32_t offset = *((uint32_t *)p_memory - 1);
void *p = (void *)((uint8_t *)p_memory - offset);
#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mi_free(p);
#else
free(p);
Expand All @@ -118,7 +118,7 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) {
bool prepad = p_pad_align;
#endif

#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
void *mem = mi_malloc(p_bytes + (prepad ? DATA_OFFSET : 0));
#else
void *mem = malloc(p_bytes + (prepad ? DATA_OFFSET : 0));
Expand Down Expand Up @@ -171,7 +171,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
#endif

if (p_bytes == 0) {
#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mi_free(mem);
#else
free(mem);
Expand All @@ -180,7 +180,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
} else {
*s = p_bytes;

#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mem = (uint8_t *)mi_realloc(mem, p_bytes + DATA_OFFSET);
#else
mem = (uint8_t *)realloc(mem, p_bytes + DATA_OFFSET);
Expand All @@ -194,7 +194,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) {
return mem + DATA_OFFSET;
}
} else {
#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mem = (uint8_t *)mi_realloc(mem, p_bytes);
#else
mem = (uint8_t *)realloc(mem, p_bytes);
Expand Down Expand Up @@ -227,13 +227,13 @@ void Memory::free_static(void *p_ptr, bool p_pad_align) {
mem_usage.sub(*s);
#endif

#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mi_free(mem);
#else
free(mem);
#endif
} else {
#ifdef MIMALLOC_ENABLED
#ifdef ALLOC_MIMALLOC
mi_free(mem);
#else
free(mem);
Expand Down

0 comments on commit 177b7e4

Please sign in to comment.