aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/SecureMemoryAllocator.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-08-05 16:55:32 +0000
committersaturneric <[email protected]>2024-08-05 16:55:32 +0000
commit795a81bd1edad59ef51e73157b5ad68cfa30e328 (patch)
treefd9c4da2f1389f0a236d806e005cabb9f5ceab41 /src/core/function/SecureMemoryAllocator.cpp
parentfix: build pipeline (diff)
parentfix: unchecking some check boxes at gnupg controller will not restart (diff)
downloadGpgFrontend-795a81bd1edad59ef51e73157b5ad68cfa30e328.tar.gz
GpgFrontend-795a81bd1edad59ef51e73157b5ad68cfa30e328.zip
fix: according to issues and test, apply some fixesv2.1.4
Diffstat (limited to 'src/core/function/SecureMemoryAllocator.cpp')
-rw-r--r--src/core/function/SecureMemoryAllocator.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp
index c24e13f2..47301038 100644
--- a/src/core/function/SecureMemoryAllocator.cpp
+++ b/src/core/function/SecureMemoryAllocator.cpp
@@ -28,42 +28,22 @@
#include "SecureMemoryAllocator.h"
-namespace GpgFrontend {
+#include <cstdlib>
-#if defined(__APPLE__) && defined(__MACH__)
+namespace GpgFrontend {
auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* {
- auto* addr = malloc(size);
+ auto* addr = std::malloc(size);
if (addr == nullptr) FLOG_F("malloc failed!");
return addr;
}
auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
- auto* addr = realloc(ptr, size);
+ auto* addr = std::realloc(ptr, size);
if (addr == nullptr) FLOG_F("realloc failed!");
return addr;
}
-void SecureMemoryAllocator::Deallocate(void* p) { free(p); }
-
-#else
-
-#include <mimalloc.h>
-
-auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* {
- auto* addr = mi_malloc(size);
- if (addr == nullptr) FLOG_F("malloc failed!");
- return addr;
-}
-
-auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
- auto* addr = mi_realloc(ptr, size);
- if (addr == nullptr) FLOG_F("realloc memory failed!");
- return addr;
-}
-
-void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); }
-
-#endif
+void SecureMemoryAllocator::Deallocate(void* p) { std::free(p); }
} // namespace GpgFrontend \ No newline at end of file