Skip to content

Commit 9c40738

Browse files
committed
[test] Added method to get pointer size in memory class
1 parent e63bd40 commit 9c40738

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tehreer-android/src/androidTest/java/com/mta/tehreer/internal/Memory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public final class Memory {
2323
TestJNI.loadLibrary();
2424
}
2525

26+
public static native int pointerSize();
27+
2628
public static native long allocate(long capacity);
2729
public static native void dispose(long pointer);
2830

tehreer-android/src/androidTest/jni/Memory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
using namespace Tehreer;
2525

26+
static jint pointerSize(JNIEnv *env, jobject obj)
27+
{
28+
return (jint)sizeof(size_t);
29+
}
30+
2631
static jlong allocate(JNIEnv *env, jobject obj, jlong capacity)
2732
{
2833
return (jlong)malloc((size_t)capacity);
@@ -39,6 +44,7 @@ static jobject buffer(JNIEnv *env, jobject obj, jlong pointer, jlong capacity)
3944
}
4045

4146
static JNINativeMethod JNI_METHODS[] = {
47+
{ "pointerSize", "()I", (void *)pointerSize },
4248
{ "allocate", "(J)J", (void *)allocate },
4349
{ "dispose", "(J)V", (void *)dispose },
4450
{ "buffer", "(JJ)Ljava/nio/ByteBuffer;", (void *)buffer },

0 commit comments

Comments
 (0)