Remove libc FFI dependency

It was only used for a single type alias that's currently usize on all platforms, so using it was overkill. This removes libc from the dependency tree on Windows, but not on Linux, though there it's only needed for dev dependencies.
This commit is contained in:
Oliver Hamlet
2025-12-06 12:47:47 +00:00
parent 5aa61abc10
commit 84a8ef55d1
4 changed files with 9 additions and 13 deletions
Generated
-1
View File
@@ -304,7 +304,6 @@ dependencies = [
name = "loot-condition-interpreter-ffi"
version = "5.3.3"
dependencies = [
"libc",
"loot-condition-interpreter",
]
-1
View File
@@ -8,7 +8,6 @@ edition.workspace = true
[dependencies]
loot-condition-interpreter = { path = ".." }
libc = "0.2"
[lib]
name = "loot_condition_interpreter_ffi"
+5 -6
View File
@@ -2,7 +2,6 @@ use std::ffi::{c_char, c_int, CStr, CString};
use std::path::PathBuf;
use std::slice;
use libc::size_t;
use loot_condition_interpreter::{Error, GameType};
use super::ERROR_MESSAGE;
@@ -68,7 +67,7 @@ pub(crate) unsafe fn to_str<'a>(c_string: *const c_char) -> Result<&'a str, c_in
pub(crate) unsafe fn to_vec<U, V, F>(
array: *const U,
array_size: size_t,
array_size: usize,
mapper: F,
) -> Result<Vec<V>, c_int>
where
@@ -86,14 +85,14 @@ where
pub(crate) unsafe fn to_str_vec<'a>(
array: *const *const c_char,
array_size: size_t,
array_size: usize,
) -> Result<Vec<&'a str>, c_int> {
to_vec(array, array_size, |c| to_str(*c))
}
pub(crate) unsafe fn to_path_buf_vec(
array: *const *const c_char,
array_size: size_t,
array_size: usize,
) -> Result<Vec<PathBuf>, c_int> {
to_vec(array, array_size, |c| to_str(*c).map(PathBuf::from))
}
@@ -105,14 +104,14 @@ unsafe fn map_plugin_version(c_object: &plugin_version) -> Result<(String, Strin
pub(crate) unsafe fn map_plugin_versions(
plugin_versions: *const plugin_version,
num_plugins: size_t,
num_plugins: usize,
) -> Result<Vec<(String, String)>, c_int> {
to_vec(plugin_versions, num_plugins, |v| map_plugin_version(v))
}
pub(crate) unsafe fn map_plugin_crcs(
plugin_crcs: *const plugin_crc,
num_entries: size_t,
num_entries: usize,
) -> Result<Vec<(String, u32)>, c_int> {
to_vec(plugin_crcs, num_entries, |v| {
to_str(v.plugin_name).map(|s| (s.into(), v.crc))
+4 -5
View File
@@ -3,7 +3,6 @@ use std::panic::catch_unwind;
use std::path::PathBuf;
use std::sync::RwLock;
use libc::size_t;
use loot_condition_interpreter::State;
use crate::constants::{
@@ -74,7 +73,7 @@ pub unsafe extern "C" fn lci_state_destroy(state: *mut lci_state) {
pub unsafe extern "C" fn lci_state_set_active_plugins(
state: *mut lci_state,
plugin_names: *const *const c_char,
num_plugins: size_t,
num_plugins: usize,
) -> c_int {
catch_unwind(|| {
if state.is_null() {
@@ -112,7 +111,7 @@ pub unsafe extern "C" fn lci_state_set_active_plugins(
pub unsafe extern "C" fn lci_state_set_plugin_versions(
state: *mut lci_state,
plugin_versions: *const plugin_version,
num_plugins: size_t,
num_plugins: usize,
) -> c_int {
catch_unwind(|| {
if state.is_null() {
@@ -150,7 +149,7 @@ pub unsafe extern "C" fn lci_state_set_plugin_versions(
pub unsafe extern "C" fn lci_state_set_crc_cache(
state: *mut lci_state,
entries: *const plugin_crc,
num_entries: size_t,
num_entries: usize,
) -> c_int {
catch_unwind(|| {
if state.is_null() {
@@ -213,7 +212,7 @@ pub unsafe extern "C" fn lci_state_clear_condition_cache(state: *mut lci_state)
pub unsafe extern "C" fn lci_state_set_additional_data_paths(
state: *mut lci_state,
paths: *const *const c_char,
num_paths: size_t,
num_paths: usize,
) -> c_int {
catch_unwind(|| {
if state.is_null() || (paths.is_null() && num_paths != 0) {