Add plist_array_free helper function to FFI

a

b
This commit is contained in:
Jackson Coxson
2025-12-13 10:55:15 -07:00
parent d2375e8f5c
commit a3dcac93b2

View File

@@ -48,6 +48,7 @@ pub use pairing_file::*;
use idevice::{Idevice, IdeviceSocket, ReadWrite};
use once_cell::sync::Lazy;
use plist_ffi::PlistWrapper;
use std::{
ffi::{CStr, CString, c_char},
ptr::null_mut,
@@ -405,3 +406,18 @@ pub unsafe extern "C" fn idevice_data_free(data: *mut u8, len: usize) {
let _ = unsafe { std::slice::from_raw_parts(data, len) };
}
}
/// Frees an array of plists allocated by this library
///
/// # Safety
/// `data` must be a pointer to data allocated by this library,
/// NOT data allocated by libplist.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn idevice_plist_array_free(plists: *mut plist_t, len: usize) {
if !plists.is_null() {
let data = unsafe { std::slice::from_raw_parts(plists, len) };
for x in data {
unsafe { plist_ffi::creation::plist_free((*x) as *mut PlistWrapper) };
}
}
}