diff options
Diffstat (limited to 'src/core/function')
-rw-r--r-- | src/core/function/SecureMemoryAllocator.cpp | 30 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 10 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.h | 3 |
3 files changed, 11 insertions, 32 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 diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index 2d9c5992..a661f183 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -236,11 +236,10 @@ class GpgContext::Impl { const GpgContextInitArgs &args) -> bool { assert(ctx != nullptr); - if (args.custom_gpgconf && !args.custom_gpgconf_path.isEmpty()) { - LOG_D() << "set custom gpgconf path: " << args.custom_gpgconf_path; - auto err = - gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_GPGCONF, - args.custom_gpgconf_path.toUtf8(), nullptr); + if (!args.gpgconf_path.isEmpty()) { + LOG_D() << "set custom gpgconf path: " << args.gpgconf_path; + auto err = gpgme_ctx_set_engine_info(ctx, GPGME_PROTOCOL_GPGCONF, + args.gpgconf_path.toUtf8(), nullptr); if (CheckGpgError(err) != GPG_ERR_NO_ERROR) { LOG_W() << "set gpg context engine info error: " @@ -284,6 +283,7 @@ class GpgContext::Impl { // set custom gpg key db path if (!args_.db_path.isEmpty()) { + LOG_D() << "set context database path to" << args_.db_path; Module::UpsertRTValue("core", "gpgme.ctx.database_path", args_.db_path); } diff --git a/src/core/function/gpg/GpgContext.h b/src/core/function/gpg/GpgContext.h index 7a7ef24b..1ff22b8a 100644 --- a/src/core/function/gpg/GpgContext.h +++ b/src/core/function/gpg/GpgContext.h @@ -46,8 +46,7 @@ struct GpgContextInitArgs { bool offline_mode = false; ///< bool auto_import_missing_key = false; ///< - bool custom_gpgconf = false; ///< - QString custom_gpgconf_path; ///< + QString gpgconf_path; ///< bool use_pinentry = false; ///< }; |