From f0001b45f91e7889c7060e45ac6c740401f7acb3 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 6 Feb 2026 03:37:54 +0800 Subject: Add FFI support for constants with C-compatible functions --- ffi/Cargo.toml | 14 ++++++++++++++ ffi/src/lib.rs | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 ffi/Cargo.toml create mode 100644 ffi/src/lib.rs (limited to 'ffi') diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml new file mode 100644 index 0000000..5d1e562 --- /dev/null +++ b/ffi/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "jvlib" +edition = "2024" +version.workspace = true + +[lib] +crate-type = ["cdylib", "staticlib"] +name = "jvlib" + +[dependencies] +libc = "0.2" + +# FFI Import +constants = { path = "../systems/_constants" } diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs new file mode 100644 index 0000000..7ffcb00 --- /dev/null +++ b/ffi/src/lib.rs @@ -0,0 +1,13 @@ +// Export constants functions +pub use constants::*; + +#[unsafe(no_mangle)] +#[allow(nonstandard_style)] +pub extern "C" fn JV_FreeString(ptr: *mut libc::c_char) { + if ptr.is_null() { + return; + } + unsafe { + drop(std::ffi::CString::from_raw(ptr)); + } +} -- cgit