mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
actually use PAGE_SIZE
This commit is contained in:
@@ -5,8 +5,11 @@ import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
class DhfsSupportNative {
|
||||
static public final int PAGE_SIZE;
|
||||
|
||||
static {
|
||||
System.load(DhfsNativeLibFinder.getLibPath().toAbsolutePath().toString());
|
||||
PAGE_SIZE = getPageSizeInternal();
|
||||
}
|
||||
|
||||
public static native void hello();
|
||||
@@ -15,6 +18,5 @@ class DhfsSupportNative {
|
||||
|
||||
static native void dropByteBuffer(long token);
|
||||
|
||||
static native int getPageSize();
|
||||
|
||||
private static native int getPageSizeInternal();
|
||||
}
|
||||
@@ -7,6 +7,9 @@ public class UninitializedByteBuffer {
|
||||
private static final Cleaner CLEANER = Cleaner.create();
|
||||
|
||||
public static ByteBuffer allocateUninitialized(int size) {
|
||||
if (size < DhfsSupportNative.PAGE_SIZE)
|
||||
return ByteBuffer.allocateDirect(size);
|
||||
|
||||
var bb = new ByteBuffer[1];
|
||||
long token = DhfsSupportNative.allocateUninitializedByteBuffer(bb, size);
|
||||
var ret = bb[0];
|
||||
|
||||
@@ -86,7 +86,7 @@ JNIEXPORT void JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_dropBy
|
||||
free((void*) addr);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_getPageSize
|
||||
JNIEXPORT jint JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_getPageSizeInternal
|
||||
(JNIEnv*, jclass) {
|
||||
return checked_cast<jint>(get_page_size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user