]> git.bitcoin.ninja Git - ldk-java/commitdiff
[C#] Free array buffers passed to C# after we've decoded them
authorMatt Corallo <git@bluematt.me>
Wed, 24 Jan 2024 03:17:10 +0000 (03:17 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 29 Jan 2024 16:37:42 +0000 (16:37 +0000)
c_sharp/src/org/ldk/util/InternalUtils.cs

index 927409e2a4e2ce7782447ff809f38bebe7edae2c..9296adf0fdc59d7a49173191a780e16f4204a0ee 100644 (file)
@@ -124,6 +124,7 @@ internal class InternalUtils {
                byte[] res = new byte[len];
                for (int i = 0; i < len; i++)
                        res[i] = getU8ArrayElem(arrptr, i);
+               bindings.free_buffer(arrptr);
                return res;
        }
        public static short[] decodeUint16Array(long arrptr) {
@@ -131,6 +132,7 @@ internal class InternalUtils {
                short[] res = new short[len];
                for (int i = 0; i < len; i++)
                        res[i] = getU16ArrayElem(arrptr, i);
+               bindings.free_buffer(arrptr);
                return res;
        }
        public static long[] decodeUint64Array(long arrptr) {
@@ -138,6 +140,7 @@ internal class InternalUtils {
                long[] res = new long[len];
                for (int i = 0; i < len; i++)
                        res[i] = getU64ArrayElem(arrptr, i);
+               bindings.free_buffer(arrptr);
                return res;
        }
 }