From: Matt Corallo Date: Sat, 13 Aug 2022 01:34:03 +0000 (+0000) Subject: Drop clone on tuple-field-fetching X-Git-Tag: v0.0.110.2^2~3 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=096b386b1bb6d440d80de4ea528ccfb58305b9e4;hp=13cdf8bde340072288b39a5e29f0946d3e095ad4;p=ldk-java Drop clone on tuple-field-fetching Early in the lifetime of the bindings here tuple-field-fetching had memory tracking issues which appear to have been solved now. Thus, we can go ahead and drop the clone, at least for has-inner types. Fixes #84. --- diff --git a/genbindings.py b/genbindings.py index 7ff9069b..b8e58bc5 100755 --- a/genbindings.py +++ b/genbindings.py @@ -816,7 +816,13 @@ with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}", owned_fn_defn = field_decl + " " + struct_name.replace("LDK", "") + "_get_" + field_name + "(" + struct_name + " *NONNULL_PTR owner)" holds_ref = False - if field_ty.rust_obj is not None and field_ty.rust_obj.replace("LDK", "") + "_clone" in clone_fns: + if field_ty.rust_obj is not None and field_ty.rust_obj in opaque_structs: + fn_defn = owned_fn_defn + write_c("static inline " + fn_defn + "{\n") + write_c("\t" + field_ty.rust_obj + " ret = " + accessor[0] + "owner" + accessor[1] + ";\n") + write_c("\tret.is_owned = false;\n") + write_c("\treturn ret;\n") + elif field_ty.rust_obj is not None and field_ty.rust_obj.replace("LDK", "") + "_clone" in clone_fns: fn_defn = owned_fn_defn write_c("static inline " + fn_defn + "{\n") if check_sfx is not None: