refactor(ffi): return null ptr instead of aborting in C API (#2478)

Make C API functions that return pointers return null in case of a
panic, instead of aborting.

Add ffi_fn! macro rules that enable default error values to be returned
by writing "?= <value>" after an ffi function's body.
This commit is contained in:
Rasmus Nylander
2021-03-26 19:26:44 +01:00
committed by GitHub
parent 68d4e4a3db
commit 895e4cf3fb
7 changed files with 33 additions and 25 deletions

View File

@@ -57,7 +57,7 @@ ffi_fn! {
hyper_clientconn { tx }
})
}))
}
} ?= std::ptr::null_mut()
}
ffi_fn! {
@@ -85,7 +85,7 @@ ffi_fn! {
};
Box::into_raw(hyper_task::boxed(fut))
}
} ?= std::ptr::null_mut()
}
ffi_fn! {
@@ -110,7 +110,7 @@ ffi_fn! {
builder: conn::Builder::new(),
exec: WeakExec::new(),
}))
}
} ?= std::ptr::null_mut()
}
ffi_fn! {