From 4f5b90400e414e77f067b8831e3296ce569352ed Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 1 May 2020 23:57:16 +0200 Subject: util: use handle_alloc_error() --- safe_libc/src/util.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/safe_libc/src/util.rs b/safe_libc/src/util.rs index e91494e..d37954c 100644 --- a/safe_libc/src/util.rs +++ b/safe_libc/src/util.rs @@ -1,5 +1,9 @@ +use alloc::alloc; + #[inline] pub fn must_succeed(p: *mut T) -> *mut T { - assert!(!p.is_null(), "allocation failure"); + if p.is_null() { + alloc::handle_alloc_error(alloc::Layout::new::()) + } p } -- cgit v1.2.3