summaryrefslogtreecommitdiffstats
path: root/safe_libc/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2020-05-01 23:57:16 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2020-05-01 23:57:16 +0200
commit4f5b90400e414e77f067b8831e3296ce569352ed (patch)
tree11170f243f1afdc1cb546230c4c47609b9c78be7 /safe_libc/src
parenta205bbb1d286d78efbb325dac1d465c6908e0026 (diff)
downloadneco-4f5b90400e414e77f067b8831e3296ce569352ed.tar
neco-4f5b90400e414e77f067b8831e3296ce569352ed.zip
util: use handle_alloc_error()
Diffstat (limited to 'safe_libc/src')
-rw-r--r--safe_libc/src/util.rs6
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
}