From eac7db447143ce66a737dc998afca585a5652b45 Mon Sep 17 00:00:00 2001 From: mikehoyle Date: Thu, 20 Oct 2022 13:58:53 -0700 Subject: [PATCH] c-bindings: Add jsonnet_realloc export This adds the realloc function as an export in c-bindings.go so that it is included in the generated header and can be used by dependent libraries. --- c-bindings/c-bindings.go | 6 ++++++ c-bindings/internal.h | 2 ++ c-bindings/libjsonnet.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/c-bindings/c-bindings.go b/c-bindings/c-bindings.go index 6b320b0..a6076e2 100644 --- a/c-bindings/c-bindings.go +++ b/c-bindings/c-bindings.go @@ -663,5 +663,11 @@ func jsonnet_set_trace_out_callback(vmRef *C.struct_JsonnetVm, cb *C.JsonnetIoWr vm.SetTraceOut(&traceOut{cb}) } +//export jsonnet_realloc +func jsonnet_realloc(vmRef *C.struct_JsonnetVm, buf *C.char, sz C.size_t) *C.char { + return C.jsonnet_internal_realloc(vmRef, buf, sz) +} + + func main() { } diff --git a/c-bindings/internal.h b/c-bindings/internal.h index a0317fd..c33afb5 100644 --- a/c-bindings/internal.h +++ b/c-bindings/internal.h @@ -46,3 +46,5 @@ int jsonnet_internal_execute_writer(JsonnetIoWriterCallback *cb, int *success); void jsonnet_internal_free_string(char *str); + +char* jsonnet_internal_realloc(struct JsonnetVm *vm, char *str, size_t sz); diff --git a/c-bindings/libjsonnet.cpp b/c-bindings/libjsonnet.cpp index 2de73b1..972cfe4 100644 --- a/c-bindings/libjsonnet.cpp +++ b/c-bindings/libjsonnet.cpp @@ -72,7 +72,7 @@ static void memory_panic(void) abort(); } -char *jsonnet_realloc(JsonnetVm *vm, char *str, size_t sz) +char *jsonnet_internal_realloc(JsonnetVm *vm, char *str, size_t sz) { (void)vm; if (str == nullptr) {