Finally our data is no need to pass any jByteArray

This commit is contained in:
tarsin committed 2022-07-22 10:08:04 +08:00
1 parent 4381eb8c3d
commit 640f75d8d9
1 file changed
+2 -9
+2 -9
View File
@@ -37,7 +37,6 @@
#define BLOCK_SIZE 4096 * 16
static JNIEnv *env;
static jbyteArray jbr;
static int cur_index = 0; // Current entry we haven't read any data from it yet
static struct archive* arc;
@@ -45,12 +44,6 @@ static struct archive* arc;
static void* archiveAddr = 0;
static jlong archiveSize = 0;
static void JNI_prepare_environment(JNIEnv* jniEnv)
{
env = jniEnv;
jbr = (*env)->NewGlobalRef(env, (*env)->NewByteArray(env, BLOCK_SIZE));
}
static int filename_is_playable_file(const char *name) {
const char *dotptr = strrchr(name, '.');
if (dotptr++) {
@@ -90,8 +83,8 @@ JNIEXPORT jint JNICALL
Java_com_hippo_UriArchiveAccessor_openArchive(JNIEnv *_, jobject thiz, jlong addr, jlong size) {
archiveAddr = (void *) addr;
archiveSize = size;
env = _;
madvise(archiveAddr, archiveSize, MADV_SEQUENTIAL | MADV_WILLNEED);
JNI_prepare_environment(_);
archive_create();
long r = archive_read_open_memory(arc, (const void *) archiveAddr, archiveSize);
if (r) {
@@ -147,4 +140,4 @@ Java_com_hippo_UriArchiveAccessor_closeArchive(JNIEnv *jniEnv, jobject thiz) {
archive_read_close(arc);
archive_read_free(arc);
}
}
}