From: Matt Corallo Date: Sat, 7 Aug 2021 21:08:09 +0000 (+0000) Subject: Update C++ demo and ldk_net to new clone API X-Git-Tag: v0.0.99.3~4^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=e9ba970572697c221b51c9a780c39f23b4bb1b97;p=ldk-c-bindings Update C++ demo and ldk_net to new clone API --- diff --git a/ldk-net/ldk_net.c b/ldk-net/ldk_net.c index 1827954..dc19e8e 100644 --- a/ldk-net/ldk_net.c +++ b/ldk-net/ldk_net.c @@ -142,12 +142,12 @@ static uint64_t sock_hash(const void* desc) { const struct Descriptor *descriptor = (const struct Descriptor*)desc; return (uint64_t)descriptor->fd; } -static void* sock_clone(const void* desc) { - const struct Descriptor *descriptor = (const struct Descriptor*)desc; +static void sock_cloned(LDKSocketDescriptor *NONNULL_PTR ldk_desc) { + const struct Descriptor *descriptor = (const struct Descriptor*)ldk_desc->this_arg; struct Descriptor *new_desc = malloc(sizeof(struct Descriptor)); new_desc->handler = descriptor->handler; new_desc->fd = descriptor->fd; - return new_desc; + ldk_desc->this_arg = (void*) new_desc; } static void sock_free(void* desc) { free(desc); @@ -163,7 +163,7 @@ static inline LDKSocketDescriptor get_descriptor(struct SocketHandler *handler, .disconnect_socket = sock_disconnect, .eq = sock_eq, .hash = sock_hash, - .clone = sock_clone, + .cloned = sock_cloned, .free = sock_free, }; return ret; diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index b2a8f92..7c6dfda 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -308,7 +308,7 @@ public: .disconnect_socket = sock_disconnect_socket, .eq = sock_eq, .hash = sock_hash, - .clone = NULL, + .cloned = NULL, .free = NULL, }; @@ -318,7 +318,7 @@ public: .disconnect_socket = sock_disconnect_socket, .eq = sock_eq, .hash = sock_hash, - .clone = NULL, + .cloned = NULL, .free = NULL, };