fixes 1220: rocksjni build fails on Windows due to variable-size array declaration (#1223)
* fixes 1220: rocksjni build fails on Windows due to variable-size array declaration using new keyword to create variable-size arrays in order to satisfy most of the compilers * fixes 1220: rocksjni build fails on Windows due to variable-size array declaration using unique_ptr keyword to create variable-size arrays in order to satisfy most of the compilers
This commit is contained in:
parent
a9d512a76b
commit
12767b3130
@ -1104,7 +1104,7 @@ std::vector<rocksdb::CompressionType> rocksdb_compression_vector_helper(
|
|||||||
*/
|
*/
|
||||||
jbyteArray rocksdb_compression_list_helper(JNIEnv* env,
|
jbyteArray rocksdb_compression_list_helper(JNIEnv* env,
|
||||||
std::vector<rocksdb::CompressionType> compressionLevels) {
|
std::vector<rocksdb::CompressionType> compressionLevels) {
|
||||||
jbyte jbuf[compressionLevels.size()];
|
std::unique_ptr<jbyte[]> jbuf = std::make_unique<jbyte[]>(compressionLevels.size());
|
||||||
for (std::vector<rocksdb::CompressionType>::size_type i = 0;
|
for (std::vector<rocksdb::CompressionType>::size_type i = 0;
|
||||||
i != compressionLevels.size(); i++) {
|
i != compressionLevels.size(); i++) {
|
||||||
jbuf[i] = compressionLevels[i];
|
jbuf[i] = compressionLevels[i];
|
||||||
@ -1113,7 +1113,7 @@ jbyteArray rocksdb_compression_list_helper(JNIEnv* env,
|
|||||||
jbyteArray jcompressionLevels = env->NewByteArray(
|
jbyteArray jcompressionLevels = env->NewByteArray(
|
||||||
static_cast<jsize>(compressionLevels.size()));
|
static_cast<jsize>(compressionLevels.size()));
|
||||||
env->SetByteArrayRegion(jcompressionLevels, 0,
|
env->SetByteArrayRegion(jcompressionLevels, 0,
|
||||||
static_cast<jsize>(compressionLevels.size()), jbuf);
|
static_cast<jsize>(compressionLevels.size()), jbuf.get());
|
||||||
return jcompressionLevels;
|
return jcompressionLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,14 +115,14 @@ jlongArray rocksdb_open_helper(JNIEnv* env, jlong jopt_handle,
|
|||||||
// check if open operation was successful
|
// check if open operation was successful
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
jsize resultsLen = 1 + len_cols; //db handle + column family handles
|
jsize resultsLen = 1 + len_cols; //db handle + column family handles
|
||||||
jlong results[resultsLen];
|
std::unique_ptr<jlong[]> results = std::make_unique<jlong[]>(resultsLen);
|
||||||
results[0] = reinterpret_cast<jlong>(db);
|
results[0] = reinterpret_cast<jlong>(db);
|
||||||
for(int i = 1; i <= len_cols; i++) {
|
for(int i = 1; i <= len_cols; i++) {
|
||||||
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
|
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
jlongArray jresults = env->NewLongArray(resultsLen);
|
jlongArray jresults = env->NewLongArray(resultsLen);
|
||||||
env->SetLongArrayRegion(jresults, 0, resultsLen, results);
|
env->SetLongArrayRegion(jresults, 0, resultsLen, results.get());
|
||||||
return jresults;
|
return jresults;
|
||||||
} else {
|
} else {
|
||||||
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "include/org_rocksdb_TtlDB.h"
|
#include "include/org_rocksdb_TtlDB.h"
|
||||||
#include "rocksdb/utilities/db_ttl.h"
|
#include "rocksdb/utilities/db_ttl.h"
|
||||||
@ -95,14 +96,14 @@ jlongArray
|
|||||||
// check if open operation was successful
|
// check if open operation was successful
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
jsize resultsLen = 1 + len_cols; //db handle + column family handles
|
jsize resultsLen = 1 + len_cols; //db handle + column family handles
|
||||||
jlong results[resultsLen];
|
std::unique_ptr<jlong[]> results = std::make_unique<jlong[]>(resultsLen);
|
||||||
results[0] = reinterpret_cast<jlong>(db);
|
results[0] = reinterpret_cast<jlong>(db);
|
||||||
for(int i = 1; i <= len_cols; i++) {
|
for(int i = 1; i <= len_cols; i++) {
|
||||||
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
|
results[i] = reinterpret_cast<jlong>(handles[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
jlongArray jresults = env->NewLongArray(resultsLen);
|
jlongArray jresults = env->NewLongArray(resultsLen);
|
||||||
env->SetLongArrayRegion(jresults, 0, resultsLen, results);
|
env->SetLongArrayRegion(jresults, 0, resultsLen, results.get());
|
||||||
return jresults;
|
return jresults;
|
||||||
} else {
|
} else {
|
||||||
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user