mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
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:
+5
-11
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user