diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-08 18:28:43 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-09 12:47:41 +0100 |
commit | 2cad45090267d6936d1f107720058b7a761f8f00 (patch) | |
tree | 72f169b2861ec5ebf5423d23890f93dbfe65b1dd /ffi/src/openpgp/keyid.rs | |
parent | 3f89bf4477018c5bd75b78253c1fed68baa4e424 (diff) |
ffi: Introduce macro for passing references from C.
Diffstat (limited to 'ffi/src/openpgp/keyid.rs')
-rw-r--r-- | ffi/src/openpgp/keyid.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ffi/src/openpgp/keyid.rs b/ffi/src/openpgp/keyid.rs index bc4a2ace..8b64d2f8 100644 --- a/ffi/src/openpgp/keyid.rs +++ b/ffi/src/openpgp/keyid.rs @@ -59,7 +59,7 @@ pub extern "system" fn sq_keyid_free(keyid: *mut KeyID) { #[no_mangle] pub extern "system" fn sq_keyid_clone(id: Option<&KeyID>) -> *mut KeyID { - let id = id.expect("KeyID is NULL"); + let id = ffi_param_ref!(id); box_raw!(id.clone()) } @@ -67,7 +67,7 @@ pub extern "system" fn sq_keyid_clone(id: Option<&KeyID>) #[no_mangle] pub extern "system" fn sq_keyid_hash(id: Option<&KeyID>) -> uint64_t { - let id = id.expect("KeyID is NULL"); + let id = ffi_param_ref!(id); let mut hasher = build_hasher(); id.hash(&mut hasher); hasher.finish() @@ -77,7 +77,7 @@ pub extern "system" fn sq_keyid_hash(id: Option<&KeyID>) #[no_mangle] pub extern "system" fn sq_keyid_to_string(id: Option<&KeyID>) -> *mut c_char { - let id = id.expect("KeyID is NULL"); + let id = ffi_param_ref!(id); CString::new(id.to_string()) .unwrap() // Errors only on internal nul bytes. .into_raw() @@ -87,7 +87,7 @@ pub extern "system" fn sq_keyid_to_string(id: Option<&KeyID>) #[no_mangle] pub extern "system" fn sq_keyid_to_hex(id: Option<&KeyID>) -> *mut c_char { - let id = id.expect("KeyID is NULL"); + let id = ffi_param_ref!(id); CString::new(id.to_hex()) .unwrap() // Errors only on internal nul bytes. .into_raw() |