1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-22 07:43:15 +00:00

Free allowed/usage class reference

This commit is contained in:
M66B 2019-08-03 18:45:23 +02:00
parent bb9a99d2cd
commit bba0a4df5e

View file

@ -57,15 +57,19 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
const char *packet = "eu/faircode/netguard/Packet";
clsPacket = jniGlobalRef(env, jniFindClass(env, packet));
ng_add_alloc(clsPacket, "clsPacket");
const char *allowed = "eu/faircode/netguard/Allowed";
clsAllowed = jniGlobalRef(env, jniFindClass(env, allowed));
ng_add_alloc(clsAllowed, "clsAllowed");
const char *rr = "eu/faircode/netguard/ResourceRecord";
clsRR = jniGlobalRef(env, jniFindClass(env, rr));
ng_add_alloc(clsRR, "clsRR");
const char *usage = "eu/faircode/netguard/Usage";
clsUsage = jniGlobalRef(env, jniFindClass(env, usage));
ng_add_alloc(clsUsage, "clsUsage");
// Raise file number limit to maximum
struct rlimit rlim;
@ -91,7 +95,13 @@ void JNI_OnUnload(JavaVM *vm, void *reserved) {
log_android(ANDROID_LOG_INFO, "JNI load GetEnv failed");
else {
(*env)->DeleteGlobalRef(env, clsPacket);
(*env)->DeleteGlobalRef(env, clsAllowed);
(*env)->DeleteGlobalRef(env, clsRR);
(*env)->DeleteGlobalRef(env, clsUsage);
ng_delete_alloc(clsPacket, __FILE__, __LINE__);
ng_delete_alloc(clsAllowed, __FILE__, __LINE__);
ng_delete_alloc(clsRR, __FILE__, __LINE__);
ng_delete_alloc(clsUsage, __FILE__, __LINE__);
}
}