diff --git a/src/ocaml_helpers.h b/src/ocaml_helpers.h index 4ef347d..4dfe4f5 100644 --- a/src/ocaml_helpers.h +++ b/src/ocaml_helpers.h @@ -27,7 +27,7 @@ static struct custom_operations binaryen_ops; #define Is_none(v) ((v) == Val_none) #define Is_some(v) Is_block(v) -#define Safe_String_val(v) strdup(String_val(v)) +#define Safe_String_val(v) memcpy(malloc(caml_string_length(v) + 1), String_val(v), caml_string_length(v) + 1) CAMLprim value caml_alloc_some(value v);