PALISADE Lattice Crypto Library
1.11.9
A lattice crypto library for software engineers by software engineers.
src
core
include
utils
blockAllocator
xallocator.h
1
// @file TODO
2
//
3
// @copyright Copyright (c) TODO
4
5
#ifndef _XALLOCATOR_H
6
#define _XALLOCATOR_H
7
8
#include <stddef.h>
9
#include "utils/inttypes.h"
10
11
// See
12
// http://www.codeproject.com/Articles/1084801/Replace-malloc-free-with-a-Fast-Fixed-Block-Memory
13
14
#ifdef __cplusplus
15
// Define AUTOMATIC_XALLOCATOR_INIT_DESTROY to automatically call
16
// xalloc_init() and xalloc_destroy() when using xallocator in C++
17
// projects. On embedded systems that never exit, you can save 1-byte
18
// of RAM storage per translation unit by undefining
19
// AUTOMATIC_XALLOCATOR_INIT_DESTROY and calling xalloc_init()
20
// manually before the OS starts.
21
#define AUTOMATIC_XALLOCATOR_INIT_DESTROY
22
#ifdef AUTOMATIC_XALLOCATOR_INIT_DESTROY
23
class
XallocInitDestroy
{
31
public
:
32
XallocInitDestroy
();
33
~
XallocInitDestroy
();
34
35
private
:
36
static
usint refCount;
37
};
38
#endif // AUTOMATIC_XALLOCATOR_INIT_DESTROY
39
#endif // __cplusplus
40
41
#ifdef __cplusplus
42
extern
"C"
{
43
#endif
44
54
void
xalloc_init();
55
63
void
xalloc_destroy();
64
67
void
* xmalloc(
size_t
size);
68
71
void
xfree(
void
* ptr);
72
76
void
* xrealloc(
void
* ptr,
size_t
size);
77
79
void
xalloc_stats();
80
81
// Macro to overload new/delete with xalloc/xfree
82
#define XALLOCATOR \
83
public: \
84
void* operator new(size_t size) { return xmalloc(size); } \
85
void operator delete(void* pObject) { xfree(pObject); }
86
87
#ifdef __cplusplus
88
}
89
#endif
90
91
#endif
XallocInitDestroy
Definition:
xallocator.h:30
Generated on Fri Dec 2 2022 21:02:06 for PALISADE Lattice Crypto Library by
1.8.13