From c877930b73c890b165e23322284e37352d7e4d8e Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 24 Jun 2020 23:17:34 +0300 Subject: [PATCH] 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. --- jni/dc_wrapper.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/jni/dc_wrapper.c b/jni/dc_wrapper.c index 245d971e5..8d943a390 100644 --- a/jni/dc_wrapper.c +++ b/jni/dc_wrapper.c @@ -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); }