Debug swcsa
[SXSI/TextCollection.git] / lzindex / heap.h
1
2   // Heap of fixed size objects, fast to alloc and especially to totally free
3
4 #ifndef HEAPINCLUDED
5 #define HEAPINCLUDED
6
7 #include "basics.h"
8
9 typedef struct sheap
10    { uint siz;      // element size
11      uint cap;      // block capacity in # of elems
12      void **blocks; // list of blocks, next is block[0]
13      void **free;   // list of free positions, each contains next
14      uint first;    // first free position in current block
15      uint totsize;  // total memory allocated here
16    } *heap;
17
18         // Creates a heap of elements of size siz
19 heap createHeap (uint siz);
20         // Gets a new element from H
21 void *mallocHeap (heap H);
22         // Frees ptr from heap H
23 void freeHeap (heap H, void *ptr);
24         // Frees everything in heap H
25 void destroyHeap (heap H);
26
27 #endif