From 8f0f1dd27c9618e8c97d95f7513ab6607385639d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 30 Jun 2022 19:00:08 +0000 Subject: [PATCH] [TS] Free arrays passed as slices from TS -> C -> Rust --- typescript_strings.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/typescript_strings.py b/typescript_strings.py index 4e458f1b..1e6b1e80 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -648,11 +648,11 @@ import * as bindings from '../bindings.mjs' if ty_info.c_ty == "int8_tArray": if copy: return "memcpy(" + dest_name + ", " + arr_name + "->elems, " + arr_len + "); FREE(" + arr_name + ")" + assert not copy if ty_info.c_ty == "ptrArray": - return "(void*) " + arr_name + "->elems /* XXX " + arr_name + " leaks */" + return "(void*) " + arr_name + "->elems" else: - assert not copy - return arr_name + "->elems /* XXX " + arr_name + " leaks */" + return arr_name + "->elems" def get_native_arr_elem(self, arr_name, idxc, ty_info): assert False # Only called if above is None def get_native_arr_ptr_call(self, ty_info): @@ -663,9 +663,9 @@ import * as bindings from '../bindings.mjs' return None def cleanup_native_arr_ref_contents(self, arr_name, dest_name, arr_len, ty_info): if ty_info.c_ty == "int8_tArray": - return None + return "FREE(" + arr_name + ");" else: - return None + return "FREE(" + arr_name + ")" def map_hu_array_elems(self, arr_name, conv_name, arr_ty, elem_ty): if elem_ty.rust_obj == "LDKu5": -- 2.39.5