diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-02-22 12:00:37 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 12:00:37 +1100 |
commit | 3b25df55b53d00cae83ef105f5e8cfc2050459d8 (patch) | |
tree | 32d33d3724db393f39b70805710263b5b891ff25 /source/core | |
parent | b8da62bf43e42e6fc895664a9faf621cbe0325c8 (diff) | |
parent | 9029f897da1052f5a16cac6dc1a3069d1f26a192 (diff) |
Merge pull request #21 from kblaschke/allow-jemalloc-from-system
Support prefixed and non-prefixed JeMalloc functions
Diffstat (limited to 'source/core')
-rw-r--r-- | source/core/CMakeLists.txt | 8 | ||||
-rw-r--r-- | source/core/StarMemory.cpp | 19 |
2 files changed, 26 insertions, 1 deletions
diff --git a/source/core/CMakeLists.txt b/source/core/CMakeLists.txt index bbad6f4..ce35500 100644 --- a/source/core/CMakeLists.txt +++ b/source/core/CMakeLists.txt @@ -214,4 +214,10 @@ ELSEIF (STAR_SYSTEM_FAMILY_WINDOWS) ENDIF () ADD_LIBRARY (star_core OBJECT ${star_core_SOURCES} ${star_core_HEADERS}) -TARGET_PRECOMPILE_HEADERS (star_core PUBLIC StarPch.hpp)
\ No newline at end of file +TARGET_PRECOMPILE_HEADERS (star_core PUBLIC StarPch.hpp) + +IF(STAR_USE_JEMALLOC AND JEMALLOC_IS_PREFIXED) + SET_SOURCE_FILES_PROPERTIES(StarMemory.cpp PROPERTIES + COMPILE_DEFINITIONS STAR_JEMALLOC_IS_PREFIXED + ) +ENDIF()
\ No newline at end of file diff --git a/source/core/StarMemory.cpp b/source/core/StarMemory.cpp index 3855283..9e73eb6 100644 --- a/source/core/StarMemory.cpp +++ b/source/core/StarMemory.cpp @@ -7,6 +7,7 @@ namespace Star { #ifdef STAR_USE_JEMALLOC +#ifdef STAR_JEMALLOC_IS_PREFIXED void* malloc(size_t size) { return je_malloc(size); } @@ -33,6 +34,24 @@ namespace Star { } void free(void* ptr) { + ::free(ptr); + } + + void free(void* ptr, size_t size) { + if (ptr) + ::sdallocx(ptr, size, 0); + } +#endif +#else + void* malloc(size_t size) { + return ::malloc(size); + } + + void* realloc(void* ptr, size_t size) { + return ::realloc(ptr, size); + } + + void free(void* ptr) { return ::free(ptr); } |