[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / LockableScore.java
index 7716950af939df3dac28f489a0cdce1dbc47cf12..a8cc6788bd2e48d7c11af3d0856bea5ba51e9410 100644 (file)
@@ -30,7 +30,19 @@ public class LockableScore extends CommonBase {
        protected void finalize() throws Throwable {
                if (ptr != 0) { bindings.LockableScore_free(ptr); } super.finalize();
        }
-
+       /**
+        * Destroys the object, freeing associated resources. After this call, any access
+        * to this object may result in a SEGFAULT or worse.
+        *
+        * You should generally NEVER call this method. You should let the garbage collector
+        * do this for you when it finalizes objects. However, it may be useful for types
+        * which represent locks and should be closed immediately to avoid holding locks
+        * until the GC runs.
+        */
+       public void destroy() {
+               if (ptr != 0) { bindings.LockableScore_free(ptr); }
+               ptr = 0;
+       }
        public static interface LockableScoreInterface {
                /**
                 * Returns the locked scorer.
@@ -43,8 +55,9 @@ public class LockableScore extends CommonBase {
                impl_holder.held = new LockableScore(new bindings.LDKLockableScore() {
                        @Override public long lock() {
                                Score ret = arg.lock();
-                               long result = ret == null ? 0 : ret.ptr;
-                               impl_holder.held.ptrs_to.add(ret);
+                               Reference.reachabilityFence(arg);
+                               long result = ret.ptr;
+                               if (impl_holder.held != null) { impl_holder.held.ptrs_to.add(ret); };
                                return result;
                        }
                });
@@ -58,7 +71,7 @@ public class LockableScore extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                Score ret_hu_conv = new Score(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }