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>
46
struct
SecureObjectDeleter
{
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
GpgFrontend::SecureMemoryAllocator
Definition:
SecureMemoryAllocator.h:36
GpgFrontend
Definition:
app.cpp:39
GpgFrontend::SecureObjectDeleter
Definition:
SecureMemoryAllocator.h:46
src
core
function
SecureMemoryAllocator.h
Generated by
1.9.1