aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-08-30 14:56:10 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-08-30 14:56:10 +0200
commitacc635b535487cde4efa75aa53d45f6969928bb8 (patch)
tree59a8af88fb8c21a2edcabf3ca0612375663b7d80
parent4e8ce87792f82e1b0b2c239dc0be4f359522ee5c (diff)
[cmark] Move wrapped allocator next to `get_default_allocator`
-rw-r--r--vendor/cmark/cmark.odin24
1 files changed, 14 insertions, 10 deletions
diff --git a/vendor/cmark/cmark.odin b/vendor/cmark/cmark.odin
index 4b6519ef4..a3f7828be 100644
--- a/vendor/cmark/cmark.odin
+++ b/vendor/cmark/cmark.odin
@@ -125,6 +125,20 @@ foreign lib {
get_default_mem_allocator :: proc() -> (mem: ^Allocator) ---
}
+// You can use the current context.allocator to make a custom allocator for CMark.
+// WARNING: It needs to remain the context.allocator for any subsequent calls into this package.
+//
+// To use:
+// alloc := get_default_allocator()
+// alloc^ = make_allocator()
+make_allocator :: proc() -> (res: Allocator) {
+ return Allocator{
+ calloc = _calloc,
+ realloc = _realloc,
+ free = _free,
+ }
+}
+
bufsize_t :: distinct i32
// Node creation, destruction, and tree traversal
@@ -477,16 +491,6 @@ free_string :: proc "c" (s: string) {
}
free :: proc{free_rawptr, free_cstring}
-// You can use the current context.allocator to make a custom allocator for CMark.
-// WARNING: It needs to remain the context.allocator for any subsequent calls into this package.
-make_allocator :: proc() -> (res: Allocator) {
- return Allocator{
- calloc = _calloc,
- realloc = _realloc,
- free = _free,
- }
-}
-
@(private)
_calloc :: proc "c" (num: c.size_t, size: c.size_t) -> (alloc: rawptr) {
context = runtime.default_context()