Skip to content

Commit 84a8ef5

Browse files
committed
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.
1 parent 5aa61ab commit 84a8ef5

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ffi/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition.workspace = true
88

99
[dependencies]
1010
loot-condition-interpreter = { path = ".." }
11-
libc = "0.2"
1211

1312
[lib]
1413
name = "loot_condition_interpreter_ffi"

ffi/src/helpers.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::ffi::{c_char, c_int, CStr, CString};
22
use std::path::PathBuf;
33
use std::slice;
44

5-
use libc::size_t;
65
use loot_condition_interpreter::{Error, GameType};
76

87
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
6867

6968
pub(crate) unsafe fn to_vec<U, V, F>(
7069
array: *const U,
71-
array_size: size_t,
70+
array_size: usize,
7271
mapper: F,
7372
) -> Result<Vec<V>, c_int>
7473
where
@@ -86,14 +85,14 @@ where
8685

8786
pub(crate) unsafe fn to_str_vec<'a>(
8887
array: *const *const c_char,
89-
array_size: size_t,
88+
array_size: usize,
9089
) -> Result<Vec<&'a str>, c_int> {
9190
to_vec(array, array_size, |c| to_str(*c))
9291
}
9392

9493
pub(crate) unsafe fn to_path_buf_vec(
9594
array: *const *const c_char,
96-
array_size: size_t,
95+
array_size: usize,
9796
) -> Result<Vec<PathBuf>, c_int> {
9897
to_vec(array, array_size, |c| to_str(*c).map(PathBuf::from))
9998
}
@@ -105,14 +104,14 @@ unsafe fn map_plugin_version(c_object: &plugin_version) -> Result<(String, Strin
105104

106105
pub(crate) unsafe fn map_plugin_versions(
107106
plugin_versions: *const plugin_version,
108-
num_plugins: size_t,
107+
num_plugins: usize,
109108
) -> Result<Vec<(String, String)>, c_int> {
110109
to_vec(plugin_versions, num_plugins, |v| map_plugin_version(v))
111110
}
112111

113112
pub(crate) unsafe fn map_plugin_crcs(
114113
plugin_crcs: *const plugin_crc,
115-
num_entries: size_t,
114+
num_entries: usize,
116115
) -> Result<Vec<(String, u32)>, c_int> {
117116
to_vec(plugin_crcs, num_entries, |v| {
118117
to_str(v.plugin_name).map(|s| (s.into(), v.crc))

ffi/src/state.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::panic::catch_unwind;
33
use std::path::PathBuf;
44
use std::sync::RwLock;
55

6-
use libc::size_t;
76
use loot_condition_interpreter::State;
87

98
use crate::constants::{
@@ -74,7 +73,7 @@ pub unsafe extern "C" fn lci_state_destroy(state: *mut lci_state) {
7473
pub unsafe extern "C" fn lci_state_set_active_plugins(
7574
state: *mut lci_state,
7675
plugin_names: *const *const c_char,
77-
num_plugins: size_t,
76+
num_plugins: usize,
7877
) -> c_int {
7978
catch_unwind(|| {
8079
if state.is_null() {
@@ -112,7 +111,7 @@ pub unsafe extern "C" fn lci_state_set_active_plugins(
112111
pub unsafe extern "C" fn lci_state_set_plugin_versions(
113112
state: *mut lci_state,
114113
plugin_versions: *const plugin_version,
115-
num_plugins: size_t,
114+
num_plugins: usize,
116115
) -> c_int {
117116
catch_unwind(|| {
118117
if state.is_null() {
@@ -150,7 +149,7 @@ pub unsafe extern "C" fn lci_state_set_plugin_versions(
150149
pub unsafe extern "C" fn lci_state_set_crc_cache(
151150
state: *mut lci_state,
152151
entries: *const plugin_crc,
153-
num_entries: size_t,
152+
num_entries: usize,
154153
) -> c_int {
155154
catch_unwind(|| {
156155
if state.is_null() {
@@ -213,7 +212,7 @@ pub unsafe extern "C" fn lci_state_clear_condition_cache(state: *mut lci_state)
213212
pub unsafe extern "C" fn lci_state_set_additional_data_paths(
214213
state: *mut lci_state,
215214
paths: *const *const c_char,
216-
num_paths: size_t,
215+
num_paths: usize,
217216
) -> c_int {
218217
catch_unwind(|| {
219218
if state.is_null() || (paths.is_null() && num_paths != 0) {

0 commit comments

Comments
 (0)