diff --git a/src/dc_array.rs b/src/dc_array.rs index 475e9d4a5..495a65b99 100644 --- a/src/dc_array.rs +++ b/src/dc_array.rs @@ -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); }