Move dc_array_unref logic inside dc_array_t implementation

This will allow to make dc_array_t members private in the future.
This commit is contained in:
Alexander Krotov
2019-07-23 01:47:58 +03:00
parent ea84edf13a
commit ea3c89e913

View File

@@ -47,6 +47,14 @@ impl dc_array_t {
pub fn len(&self) -> usize {
self.array.len()
}
pub unsafe fn unref(&mut self) {
if self.type_0 == DC_ARRAY_LOCATIONS {
for &e in self.array.iter() {
Box::from_raw(e as *mut dc_location);
}
}
}
}
/**
@@ -61,11 +69,6 @@ pub unsafe fn dc_array_unref(array: *mut dc_array_t) {
if array.is_null() {
return;
}
if (*array).type_0 == DC_ARRAY_LOCATIONS {
for &e in (*array).array.iter() {
Box::from_raw(e as *mut dc_location);
}
}
Box::from_raw(array);
}