From 18ada37e4cc10e783c5b810404e85f3804275733 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:47:43 +1000 Subject: jemalloc (2) --- source/CMakeLists.txt | 3 +++ source/core/StarMemory.cpp | 18 ++++++++++++++++++ source/vcpkg.json | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index abcdff1..bb1e7ad 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -462,6 +462,9 @@ if(STAR_USE_JEMALLOC) pkg_check_modules(JEMALLOC REQUIRED IMPORTED_TARGET GLOBAL jemalloc) set(STAR_EXT_LIBS PkgConfig::JEMALLOC) + if (STAR_SYSTEM_WINDOWS OR STAR_SYSTEM_MACOS) + set_flag(STAR_JEMALLOC_IS_PREFIXED) + endif() endif() if (STAR_USE_MIMALLOC) diff --git a/source/core/StarMemory.cpp b/source/core/StarMemory.cpp index 9a9b2d2..c7818f3 100644 --- a/source/core/StarMemory.cpp +++ b/source/core/StarMemory.cpp @@ -19,6 +19,7 @@ static bool _rpm_linker_ref = rpm_linker_ref(); namespace Star { #ifdef STAR_USE_JEMALLOC +#ifdef STAR_JEMALLOC_IS_PREFIXED void* malloc(size_t size) { return je_malloc(size); } @@ -35,6 +36,23 @@ namespace Star { if (ptr) je_sdallocx(ptr, size, 0); } +#else + void* malloc(size_t size) { + return ::malloc(size); + } + + void* realloc(void* ptr, size_t size) { + return ::realloc(ptr, size); + } + + void free(void* ptr) { + ::free(ptr); + } + + void free(void* ptr, size_t size) { + ::free(ptr); + } +#endif #elif STAR_USE_MIMALLOC void* malloc(size_t size) { return mi_malloc(size); diff --git a/source/vcpkg.json b/source/vcpkg.json index f6aa482..446fb4a 100644 --- a/source/vcpkg.json +++ b/source/vcpkg.json @@ -11,7 +11,7 @@ "opus", "zstd", "mimalloc", - "jemalloc", + { "name": "jemalloc", "platform": "!osx" }, "pkgconf" ] } \ No newline at end of file -- cgit v1.2.3