Skip to content

Commit 628aa39

Browse files
committed
Doh!
1 parent 8f04692 commit 628aa39

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Java.Interop;
5+
6+
internal struct JniObjectReferenceControlBlock {
7+
public IntPtr handle;
8+
public int handle_type;
9+
public IntPtr weak_handle;
10+
public int refs_added;
11+
12+
public static readonly int Size = Marshal.SizeOf<JniObjectReferenceControlBlock>();
13+
14+
public static unsafe IntPtr Alloc () =>
15+
(IntPtr) NativeMemory.AllocZeroed (1, (uint) Size);
16+
17+
public static unsafe void Free (ref IntPtr value)
18+
{
19+
if (value == 0) {
20+
return;
21+
}
22+
NativeMemory.Free ((void*) value);
23+
value = IntPtr.Zero;
24+
}
25+
}

0 commit comments

Comments
 (0)