From 2751c19a7aa0f70d76c0581f27fca9d15214e5ff Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 16 Jan 2019 17:35:42 +0100 Subject: ffi: Use the new set of macros. - First, for the two existing functions with an error-pointer. --- ffi/src/core.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'ffi') 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. -- cgit v1.2.3