Skip to content

Commit 096b386

Browse files
committed
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.
1 parent 13cdf8b commit 096b386

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

genbindings.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,13 @@ def create_getter(struct_name, field_decl, field_name, accessor, check_sfx):
816816
owned_fn_defn = field_decl + " " + struct_name.replace("LDK", "") + "_get_" + field_name + "(" + struct_name + " *NONNULL_PTR owner)"
817817

818818
holds_ref = False
819-
if field_ty.rust_obj is not None and field_ty.rust_obj.replace("LDK", "") + "_clone" in clone_fns:
819+
if field_ty.rust_obj is not None and field_ty.rust_obj in opaque_structs:
820+
fn_defn = owned_fn_defn
821+
write_c("static inline " + fn_defn + "{\n")
822+
write_c("\t" + field_ty.rust_obj + " ret = " + accessor[0] + "owner" + accessor[1] + ";\n")
823+
write_c("\tret.is_owned = false;\n")
824+
write_c("\treturn ret;\n")
825+
elif field_ty.rust_obj is not None and field_ty.rust_obj.replace("LDK", "") + "_clone" in clone_fns:
820826
fn_defn = owned_fn_defn
821827
write_c("static inline " + fn_defn + "{\n")
822828
if check_sfx is not None:

0 commit comments

Comments
 (0)