From: Matt Corallo Date: Tue, 19 Oct 2021 04:03:39 +0000 (+0000) Subject: Drop requires_clone ret_conv cloning in complex enums X-Git-Tag: v0.0.103.1~1^2~13 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=commitdiff_plain;h=a05d98212a06a79b3dedc8b6a07e24c343752182 Drop requires_clone ret_conv cloning in complex enums requires_clone is supposed to be aboug arg_conv, not ret_conv so its mis-labeled anyway. Somewhat unclear exactly what this was for. Memory leaks are reduced to: 169 allocations remained for 1141984 bytes. --- diff --git a/gen_type_mapping.py b/gen_type_mapping.py index c8064da1..250619d3 100644 --- a/gen_type_mapping.py +++ b/gen_type_mapping.py @@ -352,14 +352,8 @@ class TypeMappingGenerator: ret_conv = ("uint64_t " + ty_info.var_name + "_ref = ((uint64_t)&", ") | 1;") if not holds_ref: ret_conv = (ty_info.rust_obj + " *" + ty_info.var_name + "_copy = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n", "") - if ty_info.requires_clone == True: # Set in object array mapping - if (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns: - ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&", ");\n") - else: - ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", "; // Warning: We likely need to clone here, but no clone is available for " + ty_inf.rust_obj + "\n") - else: - ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", ";\n") - ret_conv = (ret_conv[0], ret_conv[1] + "uint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_copy;") + ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = ", "") + ret_conv = (ret_conv[0], ";\nuint64_t " + ty_info.var_name + "_ref = (uint64_t)" + ty_info.var_name + "_copy;") return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, ret_conv = ret_conv, ret_conv_name = ty_info.var_name + "_ref",