mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-18 20:02:22 -07:00
[cmark] Add static library for Linux
Built on Ubuntu 20.04.3 LTS. Remove Odin allocator wrapper.
This commit is contained in:
Vendored
+5
-36
@@ -8,7 +8,6 @@ package cmark
|
||||
|
||||
import "core:c"
|
||||
import "core:c/libc"
|
||||
import "core:runtime"
|
||||
|
||||
BINDING_VERSION :: Version_Info{major = 0, minor = 30, patch = 2}
|
||||
|
||||
@@ -16,6 +15,10 @@ when ODIN_OS == .Windows {
|
||||
foreign import lib {
|
||||
"cmark_static.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
foreign import lib {
|
||||
"libcmark.a",
|
||||
}
|
||||
}
|
||||
|
||||
Option :: enum c.int {
|
||||
@@ -125,20 +128,6 @@ 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
|
||||
@@ -489,24 +478,4 @@ free_cstring :: proc "c" (str: cstring) {
|
||||
free_string :: proc "c" (s: string) {
|
||||
free_rawptr(raw_data(s))
|
||||
}
|
||||
free :: proc{free_rawptr, free_cstring}
|
||||
|
||||
@(private)
|
||||
_calloc :: proc "c" (num: c.size_t, size: c.size_t) -> (alloc: rawptr) {
|
||||
context = runtime.default_context()
|
||||
data, _ := runtime.mem_alloc(int(num * size), 2 * align_of(rawptr), context.allocator, {})
|
||||
return raw_data(data)
|
||||
}
|
||||
|
||||
@(private)
|
||||
_realloc :: proc "c" (ptr: rawptr, new_size: c.size_t) -> (alloc: rawptr) {
|
||||
context = runtime.default_context()
|
||||
data, _ := runtime.mem_resize(ptr, {}, int(new_size), 2 * align_of(rawptr), context.allocator, {})
|
||||
return raw_data(data)
|
||||
}
|
||||
|
||||
@(private)
|
||||
_free :: proc "c" (ptr: rawptr) {
|
||||
context = runtime.default_context()
|
||||
runtime.mem_free(ptr, context.allocator, {})
|
||||
}
|
||||
free :: proc{free_rawptr, free_cstring}
|
||||
Vendored
-12
@@ -114,16 +114,4 @@ package cmark
|
||||
|
||||
Nodes must only be modified after an `.Exit` event, or an `.Enter` event for
|
||||
leaf nodes.
|
||||
|
||||
Wrapping the context.allocator for CMark's use:
|
||||
|
||||
```odin
|
||||
using cm
|
||||
|
||||
alloc := cm.get_default_mem_allocator()
|
||||
alloc^ = cm.make_allocator()
|
||||
|
||||
... proceed as usual, but keep in mind that `context.allocator` can't change
|
||||
for any of the calls to this package.
|
||||
```
|
||||
*/
|
||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user