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:
@@ -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! {
|
||||
|
||||
Reference in New Issue
Block a user