summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-01-16 17:35:42 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-01-16 17:35:42 +0100
commit2751c19a7aa0f70d76c0581f27fca9d15214e5ff (patch)
tree92a054b426ce4e72b72c10f66866981dee431512 /ffi
parent7244f9e566f95b105d4cc411edb00f1fe3874dc6 (diff)
ffi: Use the new set of macros.
- First, for the two existing functions with an error-pointer.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/src/core.rs24
1 files changed, 4 insertions, 20 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs
index d1b74437..95faaee8 100644
--- a/ffi/src/core.rs
+++ b/ffi/src/core.rs
@@ -100,18 +100,10 @@ pub extern "system" fn sq_context_last_error(ctx: *mut Context)
pub extern "system" fn sq_context_new(domain: *const c_char,
errp: Option<&mut *mut failure::Error>)
-> *mut Context {
+ ffi_make_fry_from_errp!(errp);
let domain = ffi_param_cstr!(domain).to_string_lossy();
- match core::Context::new(&domain) {
- Ok(context) =>
- box_raw!(Context::new(context)),
- Err(e) => {
- if let Some(errp) = errp {
- *errp = box_raw!(e);
- }
- ptr::null_mut()
- },
- }
+ ffi_try_box!(core::Context::new(&domain).map(|ctx| Context::new(ctx)))
}
/// Frees a context.
@@ -190,18 +182,10 @@ pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t {
pub extern "system" fn sq_config_build(cfg: *mut Config,
errp: Option<&mut *mut failure::Error>)
-> *mut Context {
+ ffi_make_fry_from_errp!(errp);
let cfg = ffi_param_move!(cfg);
- match cfg.build() {
- Ok(context) =>
- box_raw!(Context::new(context)),
- Err(e) => {
- if let Some(errp) = errp {
- *errp = box_raw!(e);
- }
- ptr::null_mut()
- },
- }
+ ffi_try_box!(cfg.build().map(|ctx| Context::new(ctx)))
}
/// Sets the directory containing shared state.