From ea3c89e913eb387a225dcadf0e0d5633488ffb13 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 23 Jul 2019 01:47:58 +0300 Subject: [PATCH] Move dc_array_unref logic inside dc_array_t implementation This will allow to make dc_array_t members private in the future. --- src/dc_array.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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); }