summaryrefslogtreecommitdiffstats
path: root/safe_libc/src
diff options
context:
space:
mode:
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
}