From 51319f89e89c6fc6f8acc0a64b65d78f703b7509 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 23 Jul 2019 21:20:55 +0300 Subject: [PATCH] Create dc_array_t in dc_get_locations without unsafe --- src/dc_location.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/dc_location.rs b/src/dc_location.rs index b529ad123..90c4d84f0 100644 --- a/src/dc_location.rs +++ b/src/dc_location.rs @@ -247,17 +247,12 @@ pub fn dc_get_locations( Ok(loc) }, |locations| { - let ret = dc_array_new_locations(500); + let mut ret = dc_array_t::new_locations(500); for location in locations { - unsafe { - dc_array_add_ptr( - ret, - Box::into_raw(Box::new(location?)) as *mut libc::c_void, - ) - }; + ret.add_ptr(Box::into_raw(Box::new(location?)) as *mut libc::c_void); } - Ok(ret) + Ok(ret.as_ptr()) }, ) .unwrap_or_else(|_| std::ptr::null_mut())