diff --git a/java/rocksjni/slice.cc b/java/rocksjni/slice.cc index 6ea8bab3e..980dec8a1 100644 --- a/java/rocksjni/slice.cc +++ b/java/rocksjni/slice.cc @@ -33,7 +33,7 @@ void Java_org_rocksdb_AbstractSlice_createNewSliceFromString( memcpy(buf, str, len); env->ReleaseStringUTFChars(jstr, str); - rocksdb::Slice* slice = new rocksdb::Slice(buf); + const auto slice = new rocksdb::Slice(buf); rocksdb::AbstractSliceJni::setHandle(env, jobj, slice); } @@ -44,7 +44,7 @@ void Java_org_rocksdb_AbstractSlice_createNewSliceFromString( */ jint Java_org_rocksdb_AbstractSlice_size0( JNIEnv* env, jobject jobj, jlong handle) { - const rocksdb::Slice* slice = reinterpret_cast(handle); + const auto slice = reinterpret_cast(handle); return static_cast(slice->size()); } @@ -55,7 +55,7 @@ jint Java_org_rocksdb_AbstractSlice_size0( */ jboolean Java_org_rocksdb_AbstractSlice_empty0( JNIEnv* env, jobject jobj, jlong handle) { - const rocksdb::Slice* slice = reinterpret_cast(handle); + const auto slice = reinterpret_cast(handle); return slice->empty(); } @@ -66,7 +66,7 @@ jboolean Java_org_rocksdb_AbstractSlice_empty0( */ jstring Java_org_rocksdb_AbstractSlice_toString0( JNIEnv* env, jobject jobj, jlong handle, jboolean hex) { - const rocksdb::Slice* slice = reinterpret_cast(handle); + const auto slice = reinterpret_cast(handle); const std::string s = slice->ToString(hex); return env->NewStringUTF(s.c_str()); } @@ -78,8 +78,8 @@ jstring Java_org_rocksdb_AbstractSlice_toString0( */ jint Java_org_rocksdb_AbstractSlice_compare0( JNIEnv* env, jobject jobj, jlong handle, jlong otherHandle) { - const rocksdb::Slice* slice = reinterpret_cast(handle); - const rocksdb::Slice* otherSlice = + const auto slice = reinterpret_cast(handle); + const auto otherSlice = reinterpret_cast(otherHandle); return slice->compare(*otherSlice); } @@ -91,8 +91,8 @@ jint Java_org_rocksdb_AbstractSlice_compare0( */ jboolean Java_org_rocksdb_AbstractSlice_startsWith0( JNIEnv* env, jobject jobj, jlong handle, jlong otherHandle) { - auto slice = reinterpret_cast(handle); - auto otherSlice = + const auto slice = reinterpret_cast(handle); + const auto otherSlice = reinterpret_cast(otherHandle); return slice->starts_with(*otherSlice); } @@ -124,7 +124,7 @@ void Java_org_rocksdb_Slice_createNewSlice0( jbyte* ptrData = new jbyte[len]; env->GetByteArrayRegion(data, offset, len, ptrData); - const rocksdb::Slice* slice = new rocksdb::Slice((const char*)ptrData, len); + const auto slice = new rocksdb::Slice((const char*)ptrData, len); rocksdb::AbstractSliceJni::setHandle(env, jobj, slice); } @@ -145,7 +145,7 @@ void Java_org_rocksdb_Slice_createNewSlice1( memcpy(buf, ptrData, len - 1); buf[len-1]='\0'; - const rocksdb::Slice* slice = + const auto slice = new rocksdb::Slice(buf, len - 1); rocksdb::AbstractSliceJni::setHandle(env, jobj, slice); @@ -160,7 +160,7 @@ void Java_org_rocksdb_Slice_createNewSlice1( */ jbyteArray Java_org_rocksdb_Slice_data0( JNIEnv* env, jobject jobj, jlong handle) { - auto slice = reinterpret_cast(handle); + const auto slice = reinterpret_cast(handle); const int len = static_cast(slice->size()); const jbyteArray data = env->NewByteArray(len); env->SetByteArrayRegion(data, 0, len, @@ -175,10 +175,14 @@ jbyteArray Java_org_rocksdb_Slice_data0( */ void Java_org_rocksdb_Slice_disposeInternalBuf( JNIEnv * env, jobject jobj, jlong handle) { - const rocksdb::Slice* slice = reinterpret_cast(handle); - delete [] slice->data_; + const auto slice = reinterpret_cast(handle); + delete [] slice->data_; } +// + +//