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 <cstdint>
32
#include <memory>
33
34
#include "core/utils/LogUtils.h"
35
36
namespace
GpgFrontend
{
37
38
class
GPGFRONTEND_CORE_EXPORT
SecureMemoryAllocator
{
39
public
:
40
static
auto
Allocate(std::size_t) ->
void
*;
41
42
static
auto
Reallocate(
void
*, std::size_t) ->
void
*;
43
44
static
void
Deallocate(
void
*);
45
};
46
47
template
<
typename
T>
48
struct
SecureObjectDeleter
{
49
void
operator()(T *ptr) {
50
if
(ptr) {
51
ptr->~T();
52
SecureMemoryAllocator::Deallocate(ptr);
53
}
54
}
55
};
56
57
template
<
typename
T>
58
using
SecureUniquePtr = std::unique_ptr<T, SecureObjectDeleter<T>>;
59
60
}
// namespace GpgFrontend
GpgFrontend::SecureMemoryAllocator
Definition:
SecureMemoryAllocator.h:38
GpgFrontend
Definition:
app.cpp:39
GpgFrontend::SecureObjectDeleter
Definition:
SecureMemoryAllocator.h:48
src
core
function
SecureMemoryAllocator.h
Generated by
1.9.1