From 1f504ddf2d09f62ea3a68aab6deeac24aa813b54 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 15 Jan 2019 16:11:25 +0100 Subject: ffi: Introduce macro for *char parameters. --- ffi/src/openpgp/keyid.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ffi/src/openpgp/keyid.rs') 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()) -- cgit v1.2.3