openTRI
0.1
triHeap.h
1
#ifndef __TRIHEAP_H__
2
#define __TRIHEAP_H__
3
4
#include "triTypes.h"
5
6
typedef
struct
triHeapStruct
triHeap
;
7
8
struct
triHeapStruct
9
{
10
void
* _base;
11
triU32 _size;
12
triU32 _block_size;
13
14
triU32 _free;
15
triU32 _largest_block;
16
triU32 _largest_update;
17
18
triU32 _n_blocks;
19
triU32* _blocks;
20
};
21
22
23
// Macro to define a heap within a C file without having to call triHeapCreate
24
#define TRI_HEAP( name, sz, align ) \
25
triU8 name##_heap[sz]; \
26
triU32 name##_blocks[sz/align] = { (sz/align)|(0x3<<30) }; \
27
triHeap name = { ._base = name##_heap, ._size = sz, ._block_size = align, ._free = sz / align, \
28
._largest_block = sz / align, ._largest_update = 0, ._n_blocks = sz / align, ._blocks = name##_blocks };
29
30
31
triHeap
* triHeapCreate(
void
* base, triU32 size, triU32 block_size );
32
void
triHeapDestroy(
triHeap
* mem );
33
34
#ifdef _DEBUG
35
void
__triHeapwalk(
triHeap
* mem );
36
#endif
37
38
39
void
* triHeapAlloc(
triHeap
* mem, triU32 size );
40
void
* triHeapRealloc(
triHeap
* mem,
void
* ptr, triU32 size );
41
void
* triHeapCalloc(
triHeap
* mem, triU32 size );
42
void
triHeapFree(
triHeap
* mem,
void
* ptr );
43
void
triHeapFreeAll(
triHeap
* mem );
44
45
triU32 triHeapMemavail(
triHeap
* mem );
46
triU32 triHeapLargestblock(
triHeap
* mem );
47
#endif
triHeapStruct
Definition
triHeap.h:9
Generated by
1.12.0