From: Matt Corallo Date: Sun, 18 Jul 2021 02:09:45 +0000 (+0000) Subject: Provide full (new) struct to trait clone functions X-Git-Tag: v0.0.99.3~4^2~8 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=d7a6aee121ef6089376b0c856e11c4b1d70521b6;hp=d7a6aee121ef6089376b0c856e11c4b1d70521b6;p=ldk-c-bindings Provide full (new) struct to trait clone functions Previously, when we went to clone a trait-implementation struct, we'd provide only the `this_arg` void pointer, requiring that the `this_arg` pointer be cloned into a new object while all remaining fields are copied over exactly. This has a few important limitations: * When a struct is cloned, it is not possible to set a `free` function to free any new data placed in `this_arg` without it also being set on the original struct. * Supertrait fields cannot be updated in the subtrait clone method, including the `this_arg` and `free` methods. The first limitation prevents us from setting `free` after a clone when the original trait may or may not have had `free` set. For example, if the original trait was created with a `Obj_as_Trait` method, cloned copies would never be free'd. The second limitation prevents us from keeping the super and subtrait `this_arg` fields in sync, in addition to limitations similar to the above. This resulted in Java code double-free'ing the `this_arg` field in `InMemorySigner` objects which were accessed as both `Sign` and `BaseSign` traits. ---