diff options
author | saturneric <[email protected]> | 2023-12-14 08:58:53 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-12-14 08:58:53 +0000 |
commit | 79783510863445b5068eef092a1f2650733a5b02 (patch) | |
tree | d8e6070b85467451c658ce4122c45a5a132e6d44 /src/core/utils/MemoryUtils.h | |
parent | fix: slove a memory issue found by valgrind (diff) | |
download | GpgFrontend-79783510863445b5068eef092a1f2650733a5b02.tar.gz GpgFrontend-79783510863445b5068eef092a1f2650733a5b02.zip |
fix: slove some memory issues
Diffstat (limited to 'src/core/utils/MemoryUtils.h')
-rw-r--r-- | src/core/utils/MemoryUtils.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/utils/MemoryUtils.h b/src/core/utils/MemoryUtils.h index 6cbbfec8..4c68e864 100644 --- a/src/core/utils/MemoryUtils.h +++ b/src/core/utils/MemoryUtils.h @@ -112,8 +112,8 @@ template <typename T, typename... Args> static auto SecureCreateObject(Args &&...args) -> T * { void *mem = SecureMemoryAllocator::Allocate(sizeof(T)); if (!mem) return nullptr; - SPDLOG_TRACE("alloc secure memnory success, mem: {}", - static_cast<void *>(mem)); + SPDLOG_TRACE("alloc secure memnory success, type: {}, size: {}, addr: {}", + typeid(T).name(), sizeof(T), mem); try { return new (mem) T(std::forward<Args>(args)...); @@ -137,8 +137,9 @@ static auto SecureCreateUniqueObject(Args &&...args) -> std::unique_ptr<T, SecureObjectDeleter<T>> { void *mem = SecureMemoryAllocator::Allocate(sizeof(T)); if (!mem) throw std::bad_alloc(); - SPDLOG_TRACE("alloc secure memnory success, unique ptr, type: {}, mem: {}", - typeid(T).name(), mem); + SPDLOG_TRACE( + "alloc secure memnory success, unique ptr, type: {}, size: {}, addr: {}", + typeid(T).name(), sizeof(T), mem); try { return std::unique_ptr<T, SecureObjectDeleter<T>>( @@ -153,8 +154,9 @@ template <typename T, typename... Args> auto SecureCreateSharedObject(Args &&...args) -> std::shared_ptr<T> { void *mem = SecureMemoryAllocator::Allocate(sizeof(T)); if (!mem) throw std::bad_alloc(); - SPDLOG_TRACE("alloc secure memnory success, shared ptr, type: {}, mem: {}", - typeid(T).name(), mem); + SPDLOG_TRACE( + "alloc secure memnory success, shared ptr, type: {}, size: {}, addr: {}", + typeid(T).name(), sizeof(T), mem); try { T *obj = new (mem) T(std::forward<Args>(args)...); |