summaryrefslogtreecommitdiff
path: root/ffi
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-02-06 03:37:54 +0800
committer魏曹先生 <1992414357@qq.com>2026-02-06 03:37:54 +0800
commitf0001b45f91e7889c7060e45ac6c740401f7acb3 (patch)
tree51f0f93ecc4b1240871801b52ae0ffa77b3e8e6e /ffi
parent520925836243b9c3e60f199f11374b3eddbe3fae (diff)
Add FFI support for constants with C-compatible functions
Diffstat (limited to 'ffi')
-rw-r--r--ffi/Cargo.toml14
-rw-r--r--ffi/src/lib.rs13
2 files changed, 27 insertions, 0 deletions
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));
+ }
+}