mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 11:55:38 -04:00
Clean reader/searcher objects properly
This commit is contained in:
parent
04e6252d5f
commit
fe2ea926a3
5
kiwix.c
5
kiwix.c
@ -241,9 +241,11 @@ JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_loadZIM(JNIEnv *e
|
||||
|
||||
pthread_mutex_lock(&readerLock);
|
||||
try {
|
||||
if (reader != NULL) delete reader;
|
||||
reader = new kiwix::Reader(cPath);
|
||||
} catch (exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
reader = NULL;
|
||||
retVal = JNI_FALSE;
|
||||
}
|
||||
pthread_mutex_unlock(&readerLock);
|
||||
@ -423,10 +425,13 @@ JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_loadFulltextIndex
|
||||
std::string cPath = jni2c(path, env);
|
||||
|
||||
pthread_mutex_lock(&searcherLock);
|
||||
searcher = NULL;
|
||||
try {
|
||||
if (searcher != NULL) delete searcher;
|
||||
searcher = new kiwix::XapianSearcher(cPath);
|
||||
} catch (exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
searcher = NULL;
|
||||
retVal = JNI_FALSE;
|
||||
}
|
||||
pthread_mutex_unlock(&searcherLock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user