summaryrefslogtreecommitdiffstats
path: root/ffi/src/openpgp/keyid.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-15 16:11:25 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-15 18:02:37 +0100
commit1f504ddf2d09f62ea3a68aab6deeac24aa813b54 (patch)
treee102f9b89476e3c870cca1625aac01a02f406c33 /ffi/src/openpgp/keyid.rs
parentaf870aa2bf8b844c8fab3f09cc7942c4c761dc06 (diff)
ffi: Introduce macro for *char parameters.
Diffstat (limited to 'ffi/src/openpgp/keyid.rs')
-rw-r--r--ffi/src/openpgp/keyid.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/ffi/src/openpgp/keyid.rs b/ffi/src/openpgp/keyid.rs
index 6df8ca81..045e5133 100644
--- a/ffi/src/openpgp/keyid.rs
+++ b/ffi/src/openpgp/keyid.rs
@@ -4,7 +4,7 @@
//!
//! [`sequoia-openpgp::KeyID`]: ../../../sequoia_openpgp/enum.KeyID.html
-use std::ffi::{CString, CStr};
+use std::ffi::CString;
use std::hash::{Hash, Hasher};
use std::ptr;
use std::slice;
@@ -42,8 +42,7 @@ pub extern "system" fn sq_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID {
/// Reads a hex-encoded Key ID.
#[no_mangle]
pub extern "system" fn sq_keyid_from_hex(id: *const c_char) -> *mut KeyID {
- assert!(!id.is_null());
- let id = unsafe { CStr::from_ptr(id).to_string_lossy() };
+ let id = ffi_param_cstr!(id).to_string_lossy();
KeyID::from_hex(&id)
.map(|id| Box::into_raw(Box::new(id)))
.unwrap_or(ptr::null_mut())