diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-05-01 23:57:16 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-05-01 23:57:16 +0200 |
commit | 4f5b90400e414e77f067b8831e3296ce569352ed (patch) | |
tree | 11170f243f1afdc1cb546230c4c47609b9c78be7 /safe_libc | |
parent | a205bbb1d286d78efbb325dac1d465c6908e0026 (diff) | |
download | neco-4f5b90400e414e77f067b8831e3296ce569352ed.tar neco-4f5b90400e414e77f067b8831e3296ce569352ed.zip |
util: use handle_alloc_error()
Diffstat (limited to 'safe_libc')
-rw-r--r-- | safe_libc/src/util.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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<T>(p: *mut T) -> *mut T { - assert!(!p.is_null(), "allocation failure"); + if p.is_null() { + alloc::handle_alloc_error(alloc::Layout::new::<T>()) + } p } |