-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheap.h
executable file
·60 lines (48 loc) · 1.33 KB
/
heap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by dbyard on 02/12/2020.
//
#ifndef JETSAM_HEAP_H
#define JETSAM_HEAP_H
#include <stdlib.h>
#include <stddef.h>
/**
* Given any size_t of memory, realign it to the processor's maximum alignment.
*/
#define realign(memory) \
((memory) + (sizeof(max_align_t) - 1)) & ~(sizeof(max_align_t) - 1)
/**
* Initialize the memory heap.
* @param size minimum size of the memory heap.
*/
void g_heap_init();
/**
* Return a unique pointer from the memory heap.
* @param size the minimum size to allocate.
* @return an aligned pointer to at least the number of bytes requested, or NULL if out of heap space.
*/
void* g_heap_allocate(size_t size);
/**
* Drop in replacement for malloc() using the memory heap.
*/
void* g_heap_emulate_malloc(size_t size);
/**
* Drop in replacement for calloc() using the memory heap.
*/
void* g_heap_emulate_calloc(size_t nmemb, size_t size);
/**
* Drop in replacement for realloc() using the memory heap.
*/
void* g_heap_emulate_realloc(void* ptr, size_t size);
/**
* Drop in replacement for reallocarray() using the memory heap.
*/
void* g_heap_emulate_reallocarray(void* ptr, size_t nmemb, size_t size);
/**
* Drop in replacement for free() using the memory heap.
*/
void g_heap_emulate_free(void* ptr);
/**
* Destroy the memory heap.
*/
void g_heap_destroy();
#endif //JETSAM_HEAP_H