From 6728888b87806328b05f30b15825d05ca34026bc Mon Sep 17 00:00:00 2001 From: saturneric Date: Thu, 25 Jul 2024 13:31:16 +0200 Subject: feat: add an ASAN option to enable a memory debugging mode --- src/core/function/SecureMemoryAllocator.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/core/function/SecureMemoryAllocator.cpp') diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp index fccd09fe..f854f816 100644 --- a/src/core/function/SecureMemoryAllocator.cpp +++ b/src/core/function/SecureMemoryAllocator.cpp @@ -28,36 +28,20 @@ #include "SecureMemoryAllocator.h" -#if !defined(MACOS) && defined(DEBUG) #include -#endif namespace GpgFrontend { auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* { -#if !defined(MACOS) && defined(DEBUG) auto* addr = mi_malloc(size); -#else - auto* addr = malloc(size); -#endif return addr; } auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { -#if !defined(MACOS) && defined(DEBUG) - auto* addr = mi_realloc(ptr, size); -#else auto* addr = realloc(ptr, size); -#endif return addr; } -void SecureMemoryAllocator::Deallocate(void* p) { -#if !defined(MACOS) && defined(DEBUG) - mi_free(p); -#else - free(p); -#endif -} +void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); } } // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3 From 28b2798015633e0186fa2084f9e9803f0fea5ba0 Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 28 Jul 2024 22:44:37 +0200 Subject: fix: do not use mimalloc on macos and solve windows build issues on github actions --- src/core/function/SecureMemoryAllocator.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/core/function/SecureMemoryAllocator.cpp') diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp index f854f816..651e4085 100644 --- a/src/core/function/SecureMemoryAllocator.cpp +++ b/src/core/function/SecureMemoryAllocator.cpp @@ -28,6 +28,8 @@ #include "SecureMemoryAllocator.h" +#ifndef MACOS + #include namespace GpgFrontend { @@ -38,10 +40,28 @@ auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* { } auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { - auto* addr = realloc(ptr, size); + auto* addr = mi_realloc(ptr, size); return addr; } void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); } +#else + +namespace GpgFrontend { + +auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* { + auto* addr = malloc(size); + return addr; +} + +auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* { + auto* addr = realloc(ptr, size); + return addr; +} + +void SecureMemoryAllocator::Deallocate(void* p) { free(p); } + +#endif + } // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3