Drop requires_clone ret_conv cloning in complex enums
authorMatt Corallo <git@bluematt.me>
Tue, 19 Oct 2021 04:03:39 +0000 (04:03 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 19 Oct 2021 06:12:42 +0000 (06:12 +0000)
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.

gen_type_mapping.py

index c8064da102393465bebde71ff96a76d76ac173d0..250619d3d2a113941f8c732555ed7c36bb209c78 100644 (file)
@@ -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",