From fadcd43fee8dd67d1839cfdea5b4df1bfb5380d1 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Thu, 15 Aug 2019 20:32:28 +0300 Subject: [PATCH] Move some unsafe dc_array_* functions to FFI --- deltachat-ffi/src/lib.rs | 14 +++++++------- src/dc_array.rs | 35 ----------------------------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 31073af17..f4e8401db 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -1094,7 +1094,7 @@ pub unsafe extern "C" fn dc_array_get_latitude( ) -> libc::c_double { assert!(!array.is_null()); - dc_array::dc_array_get_latitude(array, index) + (*array).get_latitude(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_longitude( @@ -1103,7 +1103,7 @@ pub unsafe extern "C" fn dc_array_get_longitude( ) -> libc::c_double { assert!(!array.is_null()); - dc_array::dc_array_get_longitude(array, index) + (*array).get_longitude(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_accuracy( @@ -1112,7 +1112,7 @@ pub unsafe extern "C" fn dc_array_get_accuracy( ) -> libc::c_double { assert!(!array.is_null()); - dc_array::dc_array_get_accuracy(array, index) + (*array).get_accuracy(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_timestamp( @@ -1121,7 +1121,7 @@ pub unsafe extern "C" fn dc_array_get_timestamp( ) -> i64 { assert!(!array.is_null()); - dc_array::dc_array_get_timestamp(array, index) + (*array).get_timestamp(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_chat_id( @@ -1130,7 +1130,7 @@ pub unsafe extern "C" fn dc_array_get_chat_id( ) -> libc::c_uint { assert!(!array.is_null()); - dc_array::dc_array_get_chat_id(array, index) + (*array).get_chat_id(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_contact_id( @@ -1139,7 +1139,7 @@ pub unsafe extern "C" fn dc_array_get_contact_id( ) -> libc::c_uint { assert!(!array.is_null()); - dc_array::dc_array_get_contact_id(array, index) + (*array).get_contact_id(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_msg_id( @@ -1148,7 +1148,7 @@ pub unsafe extern "C" fn dc_array_get_msg_id( ) -> libc::c_uint { assert!(!array.is_null()); - dc_array::dc_array_get_msg_id(array, index) + (*array).get_msg_id(index) } #[no_mangle] pub unsafe extern "C" fn dc_array_get_marker( diff --git a/src/dc_array.rs b/src/dc_array.rs index 4faa2c14e..4f5034100 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -159,41 +159,6 @@ pub unsafe fn dc_array_get_id(array: *const dc_array_t, index: size_t) -> uint32 (*array).get_id(index) } -pub unsafe fn dc_array_get_latitude(array: *const dc_array_t, index: size_t) -> libc::c_double { - assert!(!array.is_null()); - (*array).get_latitude(index) -} - -pub unsafe fn dc_array_get_longitude(array: *const dc_array_t, index: size_t) -> libc::c_double { - assert!(!array.is_null()); - (*array).get_longitude(index) -} - -pub unsafe fn dc_array_get_accuracy(array: *const dc_array_t, index: size_t) -> libc::c_double { - assert!(!array.is_null()); - (*array).get_accuracy(index) -} - -pub unsafe fn dc_array_get_timestamp(array: *const dc_array_t, index: size_t) -> i64 { - assert!(!array.is_null()); - (*array).get_timestamp(index) -} - -pub unsafe fn dc_array_get_chat_id(array: *const dc_array_t, index: size_t) -> uint32_t { - assert!(!array.is_null()); - (*array).get_chat_id(index) -} - -pub unsafe fn dc_array_get_contact_id(array: *const dc_array_t, index: size_t) -> uint32_t { - assert!(!array.is_null()); - (*array).get_contact_id(index) -} - -pub unsafe fn dc_array_get_msg_id(array: *const dc_array_t, index: size_t) -> uint32_t { - assert!(!array.is_null()); - (*array).get_msg_id(index) -} - pub unsafe fn dc_array_get_marker(array: *const dc_array_t, index: size_t) -> *mut libc::c_char { assert!(!array.is_null());