summaryrefslogtreecommitdiff
path: root/source/luametatex/source/libraries/pplib/ppheap.c
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2022-09-16 15:53:42 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2022-09-16 15:53:42 +0200
commitc161b7d6fe142231346cc1844e6e27c0ab7718c1 (patch)
tree3fd877b8986137703e987e4651a2db8e946a0f72 /source/luametatex/source/libraries/pplib/ppheap.c
parente94fa4dc30ec28a6727aa85e17aaac18b76aeadb (diff)
downloadcontext-c161b7d6fe142231346cc1844e6e27c0ab7718c1.tar.gz
2022-09-16 14:41:00
Diffstat (limited to 'source/luametatex/source/libraries/pplib/ppheap.c')
-rw-r--r--source/luametatex/source/libraries/pplib/ppheap.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source/luametatex/source/libraries/pplib/ppheap.c b/source/luametatex/source/libraries/pplib/ppheap.c
new file mode 100644
index 000000000..f2fbc2b7e
--- /dev/null
+++ b/source/luametatex/source/libraries/pplib/ppheap.c
@@ -0,0 +1,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;
+} \ No newline at end of file