summaryrefslogtreecommitdiffstats
path: root/ffi/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ffi/src/lib.rs')
-rw-r--r--ffi/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs
index 3dd0a252..5c813a37 100644
--- a/ffi/src/lib.rs
+++ b/ffi/src/lib.rs
@@ -143,6 +143,22 @@ macro_rules! ffi_free {
/* Parameter handling. */
+/// Transfers ownership from C to Rust.
+///
+/// # Panics
+///
+/// Panics if called with NULL.
+macro_rules! ffi_param_move {
+ ($name:expr) => {{
+ if $name.is_null() {
+ panic!("Parameter {} is NULL", stringify!($name));
+ }
+ unsafe {
+ Box::from_raw($name)
+ }
+ }};
+}
+
/// Transfers a reference from C to Rust.
///
/// # Panics