Botan 3.4.0
Crypto and TLS for C&
allocator.h
Go to the documentation of this file.
1/*
2* (C) 2023 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_ALLOCATOR_HELPERS_H_
8#define BOTAN_ALLOCATOR_HELPERS_H_
9
10#include <botan/types.h>
11#include <cstring>
12
13namespace Botan {
14
15/**
16* Allocate a memory buffer by some method. This should only be used for
17* primitive types (uint8_t, uint32_t, etc).
18*
19* @param elems the number of elements
20* @param elem_size the size of each element
21* @return pointer to allocated and zeroed memory, or throw std::bad_alloc on failure
22*/
23BOTAN_PUBLIC_API(2, 3) BOTAN_MALLOC_FN void* allocate_memory(size_t elems, size_t elem_size);
24
25/**
26* Free a pointer returned by allocate_memory
27* @param p the pointer returned by allocate_memory
28* @param elems the number of elements, as passed to allocate_memory
29* @param elem_size the size of each element, as passed to allocate_memory
30*/
31BOTAN_PUBLIC_API(2, 3) void deallocate_memory(void* p, size_t elems, size_t elem_size);
32
33/**
34* Ensure the allocator is initialized
35*/
37
42
43} // namespace Botan
44
45#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
#define BOTAN_UNSTABLE_API
Definition compiler.h:44
#define BOTAN_MALLOC_FN
Definition compiler.h:108
BOTAN_MALLOC_FN void * allocate_memory(size_t elems, size_t elem_size)
Definition allocator.cpp:20
void deallocate_memory(void *p, size_t elems, size_t elem_size)
Definition allocator.cpp:48
void initialize_allocator()
Definition allocator.cpp:64