1use std::ffi::{c_char, c_void, CString};
2
3#[no_mangle]
8pub unsafe extern "C" fn pkgcraft_str_free(s: *mut c_char) {
9 if !s.is_null() {
10 unsafe { drop(CString::from_raw(s)) };
11 }
12}
13
14#[no_mangle]
19pub unsafe extern "C" fn pkgcraft_str_array_free(strs: *mut *mut c_char, len: usize) {
20 if !strs.is_null() {
21 unsafe {
22 for s in Vec::from_raw_parts(strs, len, len) {
23 drop(CString::from_raw(s));
24 }
25 }
26 }
27}
28
29#[no_mangle]
34pub unsafe extern "C" fn pkgcraft_array_free(array: *mut *mut c_void, len: usize) {
35 if !array.is_null() {
36 unsafe { Vec::from_raw_parts(array, len, len) };
37 }
38}