mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
dropByteBuffer -> releaseByteBuffer
This commit is contained in:
@@ -16,7 +16,7 @@ class DhfsSupportNative {
|
||||
|
||||
static native long allocateUninitializedByteBuffer(ByteBuffer[] bb, int size);
|
||||
|
||||
static native void dropByteBuffer(long token);
|
||||
static native void releaseByteBuffer(long token);
|
||||
|
||||
private static native int getPageSizeInternal();
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class UninitializedByteBuffer {
|
||||
var bb = new ByteBuffer[1];
|
||||
long token = DhfsSupportNative.allocateUninitializedByteBuffer(bb, size);
|
||||
var ret = bb[0];
|
||||
CLEANER.register(ret, () -> DhfsSupportNative.dropByteBuffer(token));
|
||||
CLEANER.register(ret, () -> DhfsSupportNative.releaseByteBuffer(token));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ JNIEXPORT jlong JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_alloc
|
||||
if (checked_size < MemoryHelpers::get_page_size())
|
||||
buf = malloc(checked_size);
|
||||
else
|
||||
buf = std::aligned_alloc(MemoryHelpers::get_page_size(), align_up(checked_size, MemoryHelpers::get_page_size()));
|
||||
buf = std::aligned_alloc(MemoryHelpers::get_page_size(),
|
||||
align_up(checked_size, MemoryHelpers::get_page_size()));
|
||||
|
||||
if (buf == nullptr) {
|
||||
env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), "Buffer memory allocation failed");
|
||||
@@ -39,7 +40,7 @@ JNIEXPORT jlong JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_alloc
|
||||
return token;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_dropByteBuffer
|
||||
JNIEXPORT void JNICALL Java_com_usatiuk_dhfs_supportlib_DhfsSupportNative_releaseByteBuffer
|
||||
(JNIEnv* env, jclass klass, jlong token) {
|
||||
const auto addr = checked_cast<uintptr_t>(token);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user