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

@@ -92,5 +92,5 @@ ffi_fn! {
/// Returns a static ASCII (null terminated) string of the hyper version.
fn hyper_version() -> *const libc::c_char {
VERSION_CSTR.as_ptr() as _
}
} ?= std::ptr::null()
}