Create dc_array_t in dc_get_locations without unsafe

This commit is contained in:
Alexander Krotov
2019-07-23 21:20:55 +03:00
parent 8b4acbb63a
commit 51319f89e8

View File

@@ -247,17 +247,12 @@ pub fn dc_get_locations(
Ok(loc) Ok(loc)
}, },
|locations| { |locations| {
let ret = dc_array_new_locations(500); let mut ret = dc_array_t::new_locations(500);
for location in locations { for location in locations {
unsafe { ret.add_ptr(Box::into_raw(Box::new(location?)) as *mut libc::c_void);
dc_array_add_ptr(
ret,
Box::into_raw(Box::new(location?)) as *mut libc::c_void,
)
};
} }
Ok(ret) Ok(ret.as_ptr())
}, },
) )
.unwrap_or_else(|_| std::ptr::null_mut()) .unwrap_or_else(|_| std::ptr::null_mut())