aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function')
-rw-r--r--src/core/function/SecureMemoryAllocator.cpp20
-rw-r--r--src/core/function/gpg/GpgKeyOpera.cpp4
2 files changed, 20 insertions, 4 deletions
diff --git a/src/core/function/SecureMemoryAllocator.cpp b/src/core/function/SecureMemoryAllocator.cpp
index 2c584753..02efcbe0 100644
--- a/src/core/function/SecureMemoryAllocator.cpp
+++ b/src/core/function/SecureMemoryAllocator.cpp
@@ -28,19 +28,31 @@
#include "SecureMemoryAllocator.h"
+#ifndef MACOS
#include <mimalloc.h>
+#endif
namespace GpgFrontend {
auto SecureMemoryAllocator::Allocate(std::size_t size) -> void* {
+#ifndef MACOS
auto* addr = mi_malloc(size);
+#else
+ auto* addr = malloc(size);
+#endif
+
SPDLOG_TRACE("secure memory allocator trys to alloc memory, address: {}",
static_cast<void*>(addr));
return addr;
}
auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
+#ifndef MACOS
auto* addr = mi_realloc(ptr, size);
+#else
+ auto* addr = realloc(ptr, size);
+#endif
+
SPDLOG_TRACE(
"secure memory allocator trys to realloc memory, "
"old address: {}, new address: {}",
@@ -48,6 +60,12 @@ auto SecureMemoryAllocator::Reallocate(void* ptr, std::size_t size) -> void* {
return addr;
}
-void SecureMemoryAllocator::Deallocate(void* p) { mi_free(p); }
+void SecureMemoryAllocator::Deallocate(void* p) {
+#ifndef MACOS
+ mi_free(p);
+#else
+ free(p);
+#endif
+}
} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/core/function/gpg/GpgKeyOpera.cpp b/src/core/function/gpg/GpgKeyOpera.cpp
index a89badc6..3ea9b365 100644
--- a/src/core/function/gpg/GpgKeyOpera.cpp
+++ b/src/core/function/gpg/GpgKeyOpera.cpp
@@ -199,9 +199,7 @@ void GpgKeyOpera::GenerateKey(const std::shared_ptr<GenKeyInfo>& params,
GpgGenKeyResult result;
if (CheckGpgError(err) == GPG_ERR_NO_ERROR) {
- auto temp_result =
- NewResult(gpgme_op_genkey_result(ctx.DefaultContext()));
- std::swap(temp_result, result);
+ result = NewResult(gpgme_op_genkey_result(ctx.DefaultContext()));
}
data_object->Swap({result});