Skip to content

Commit

Permalink
minor fixes for jni
Browse files Browse the repository at this point in the history
  • Loading branch information
dwing4g committed Jan 3, 2019
1 parent f1b99aa commit 7387b7f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions util/jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@ extern "C" JNIEXPORT jlong JNICALL DEF_JAVA(leveldb_1open3)
extern "C" JNIEXPORT void JNICALL DEF_JAVA(leveldb_1close)
(JNIEnv* jenv, jclass jcls, jlong handle)
{
if(handle)
{
DB* db = (DBImpl*)handle;
DBImpl* dbi = dynamic_cast<DBImpl*>(db);
Cache* cache = (dbi ? dbi->GetOptions().block_cache : 0);
delete db;
if(cache) delete cache;
}
DB* db = (DBImpl*)handle;
if(!db) return;
DBImpl* dbi = dynamic_cast<DBImpl*>(db);
Cache* cache = (dbi ? dbi->GetOptions().block_cache : 0);
delete db;
if(cache) delete cache;
}

// public static native byte[] leveldb_get(long handle, byte[] key, int keylen); // return null for not found
Expand Down Expand Up @@ -538,7 +536,7 @@ extern "C" JNIEXPORT jstring JNICALL DEF_JAVA(leveldb_1property)
(JNIEnv* jenv, jclass jcls, jlong handle, jstring property)
{
DB* db = (DB*)handle;
if(!db) return 0;
if(!db || !property) return 0;
std::string result;
const char* propptr = jenv->GetStringUTFChars(property, 0);
if(!propptr) return 0;
Expand Down

0 comments on commit 7387b7f

Please sign in to comment.