jni: use dc_array_get_id instead of dc_array_get_raw

dc_array_get_raw API prevents Rust code from storing IDs in other format
than an array of uint32_t.
This commit is contained in:
Alexander Krotov
2020-06-24 23:17:34 +03:00
parent b074732907
commit c877930b73
+5 -11
View File
@@ -117,18 +117,12 @@ static jintArray dc_array2jintArray_n_unref(JNIEnv *env, dc_array_t* ca)
if (ca) {
if (icnt) {
const uint32_t* ca_data = dc_array_get_raw(ca);
if (sizeof(uint32_t)==sizeof(jint)) {
(*env)->SetIntArrayRegion(env, ret, 0, icnt, (jint*)ca_data);
}
else {
jint* temp = calloc(icnt, sizeof(jint));
for (i = 0; i < icnt; i++) {
temp[i] = (jint)ca_data[i];
}
(*env)->SetIntArrayRegion(env, ret, 0, icnt, temp);
free(temp);
jint* temp = calloc(icnt, sizeof(jint));
for (i = 0; i < icnt; i++) {
temp[i] = (jint)dc_array_get_id(ca, i);
}
(*env)->SetIntArrayRegion(env, ret, 0, icnt, temp);
free(temp);
}
dc_array_unref(ca);
}