diff --git a/src/common.rs b/src/common.rs index 67d341a..3a59a41 100644 --- a/src/common.rs +++ b/src/common.rs @@ -123,11 +123,13 @@ impl DSSContext { (c_strs, c_ptrs) } - pub fn GetStringArray(&self, data: *mut *mut c_char, cnt: [i32; 4]) -> Result, DSSError> { + pub fn GetStringArray(&self, mut data: *mut *mut c_char, cnt: [i32; 4]) -> Result, DSSError> { self.DSSError()?; let res_cnt = cnt[0] as usize; let cdata = unsafe { from_raw_parts_mut(data, res_cnt) }; - Ok(unsafe { (*cdata).iter_mut().map(|s| CStr::from_ptr(*s).to_string_lossy().into_owned()).collect() }) + let res = unsafe { (*cdata).iter_mut().map(|s| CStr::from_ptr(*s).to_string_lossy().into_owned()).collect() }; + unsafe { dss_capi::DSS_Dispose_PPAnsiChar(&mut data, cnt[0]) }; + Ok(res) } pub fn GetFloat64ArrayGR(&self) -> Result, DSSError> {