summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luapplib/src/ppheap.c
blob: f2fbc2b7e4f7b69bc50903416c6924adb9ab30b7 (plain)
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

#include "pplib.h"

#define PPBYTES_HEAP_BLOCK 0xFFF
#define PPBYTES_HEAP_LARGE (PPBYTES_HEAP_BLOCK >> 2)
#define PPSTRUCT_HEAP_BLOCK 0xFFF
#define PPSTRUCT_HEAP_LARGE (PPSTRUCT_HEAP_BLOCK >> 2)

void ppheap_init (ppheap *heap)
{
  ppstruct_heap_init(heap, PPSTRUCT_HEAP_BLOCK, PPSTRUCT_HEAP_LARGE, 0);
  ppbytes_heap_init(heap, PPBYTES_HEAP_BLOCK, PPBYTES_HEAP_LARGE, 0);
}

void ppheap_free (ppheap *heap)
{
  ppstruct_heap_free(heap);
  ppbytes_heap_free(heap);
}

void ppheap_renew (ppheap *heap)
{
  ppstruct_heap_clear(heap);
  ppbytes_heap_clear(heap);
  ppbytes_buffer_init(heap);
}

ppbyte * ppbytes_flush (ppheap *heap, iof *O, size_t *psize)
{
  ppbyte *data;
  size_t size;
  
  //ASSERT(&heap->bytesheap == O->link);
  iof_put(O, '\0');
  data = (ppbyte *)O->buf;
  size = (size_t)iof_size(O);
  ppbytes_heap_done(heap, data, size);
  *psize = size - 1;
  return data;
}