GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
SecureMemoryAllocator.h
1 
29 #pragma once
30 
31 #include "core/GpgFrontendCoreExport.h"
32 #include "core/utils/LogUtils.h"
33 
34 namespace GpgFrontend {
35 
36 class GPGFRONTEND_CORE_EXPORT SecureMemoryAllocator {
37  public:
38  static auto Allocate(std::size_t) -> void *;
39 
40  static auto Reallocate(void *, std::size_t) -> void *;
41 
42  static void Deallocate(void *);
43 };
44 
45 template <typename T>
47  void operator()(T *ptr) {
48  if (ptr) {
49  ptr->~T();
50  SecureMemoryAllocator::Deallocate(ptr);
51  }
52  }
53 };
54 
55 template <typename T>
56 using SecureUniquePtr = std::unique_ptr<T, SecureObjectDeleter<T>>;
57 
58 } // namespace GpgFrontend
Definition: SecureMemoryAllocator.h:36
Definition: app.cpp:39
Definition: SecureMemoryAllocator.h:46