]> git.bitcoin.ninja Git - ldk-java/commitdiff
Add a new `force_free` in Java for cases where its useful
authorMatt Corallo <git@bluematt.me>
Sun, 12 May 2024 14:47:29 +0000 (14:47 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 13 May 2024 18:34:52 +0000 (18:34 +0000)
java_strings.py

index c99e83129b4bf21f68d72ae54af127dc255c94c4..7e35d17529d0e8ea127c25e104b0f73996a8f3da 100644 (file)
@@ -1418,6 +1418,9 @@ import javax.annotation.Nullable;
         java_hu_struct += "\tprotected void finalize() throws Throwable {\n"
         java_hu_struct += "\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); } super.finalize();\n"
         java_hu_struct += "\t}\n\n"
+        java_hu_struct += "\tprotected void force_free() {\n" # Used by NioPeerHandler
+        java_hu_struct += "\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); ptr = 0; }\n"
+        java_hu_struct += "\t}\n\n"
         java_hu_struct += "\tstatic " + human_ty + " constr_from_ptr(long ptr) {\n"
         java_hu_struct += "\t\tif (bindings." + struct_name.replace("LDK", "") + "_is_ok(ptr)) {\n"
         java_hu_struct += "\t\t\treturn new " + human_ty + "_OK(null, ptr);\n"