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.
This commit is contained in:
mikehoyle 2022-10-20 13:58:53 -07:00 committed by Dave Cunningham
parent 635d04f264
commit eac7db4471
3 changed files with 9 additions and 1 deletions

View File

@ -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() {
}

View File

@ -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);

View File

@ -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) {