summaryrefslogtreecommitdiff
path: root/core/tree_sitter_heap.h
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 22:03:14 -0300
committerGabriel Schneider <[email protected]>2026-11-18 22:23:51 -0300
commit99f5b10eccd95aa0066ea6fe6bb75f367ab56a47 (patch)
tree813596ea84318a7bae4fd7416ba463de8e3b7107 /core/tree_sitter_heap.h
parent92d553123673376adf6126ab90d49a22c5b833d2 (diff)
downloadpardes-99f5b10eccd95aa0066ea6fe6bb75f367ab56a47.tar.gz
pardes-99f5b10eccd95aa0066ea6fe6bb75f367ab56a47.zip
core: src/ becomes core/, pardes.zig its root.zig (the reorganisation's tree, step 2d), and every mention of a src/ path follows: the build's paths, the core's imports of its root, the tests that read the repository's files by path (lspbench's, look.zig's spans over core/look.zig), the comments that cite files, the documents and the manual (the typst corpus reads core/tutor.txt and core/plumbing); left as they were: the /src tree's served names (src/pardes.zig and the rest are the 9P tree's, not the repository's), the CHANGELOG's history, fixtures that are only strings; fs-unit-test runs from the core's root (a module of the core rooted at fs.zig had the runtime's and the devices' `core` be fs.zig); nothing else changes: the ledger (pardes.test.* now root.test.*), frames byte-identical, replicas and process-test the base's
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/tree_sitter_heap.h')
-rw-r--r--core/tree_sitter_heap.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/tree_sitter_heap.h b/core/tree_sitter_heap.h
new file mode 100644
index 00000000..66083be8
--- /dev/null
+++ b/core/tree_sitter_heap.h
@@ -0,0 +1,27 @@
+/* Forced into every tree-sitter grammar build ahead of its own source
+ * (build.zig passes -include). A few external scanners (bash, markdown,
+ * markdown_inline, python, typst) call malloc, calloc, realloc and free
+ * themselves rather than tree-sitter's ts_malloc and friends, so they would
+ * allocate from libc behind the Zig allocator syntax.zig hands the runtime.
+ * stdlib.h comes first so its declarations are made with the real names;
+ * from here on the four names are the runtime's current allocator functions,
+ * the ones ts_set_allocator sets. The scanners that do use ts_malloc get the
+ * same through tree_sitter/alloc.h and TREE_SITTER_REUSE_ALLOCATOR. A scanner
+ * frees only what it allocated itself, so none of this memory crosses into
+ * the runtime or out of it. */
+#ifndef PARDES_TREE_SITTER_HEAP_H
+#define PARDES_TREE_SITTER_HEAP_H
+
+#include <stdlib.h>
+
+extern void *(*ts_current_malloc)(size_t size);
+extern void *(*ts_current_calloc)(size_t count, size_t size);
+extern void *(*ts_current_realloc)(void *ptr, size_t size);
+extern void (*ts_current_free)(void *ptr);
+
+#define malloc(size) ts_current_malloc(size)
+#define calloc(count, size) ts_current_calloc(count, size)
+#define realloc(ptr, size) ts_current_realloc(ptr, size)
+#define free(ptr) ts_current_free(ptr)
+
+#endif