From e90c813528d27074fddbf8886167f4a0494a243b Mon Sep 17 00:00:00 2001 From: Skgland Date: Thu, 20 Nov 2025 21:13:17 +0100 Subject: [PATCH] return an AllocError instead of panicing in Heap::with_cell_capacity --- src/machine/heap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/machine/heap.rs b/src/machine/heap.rs index 3c92f29b..18c7addf 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -596,7 +596,7 @@ impl Heap { self.resource_err_loc } - pub(crate) fn with_cell_capacity(cap: usize) -> Result { + pub(crate) fn with_cell_capacity(cap: usize) -> Result { let ptr = unsafe { let layout = alloc::Layout::from_size_align( cap * size_of::(), @@ -607,7 +607,7 @@ impl Heap { }; if ptr.is_null() { - panic!("could not allocate {} bytes for heap!", heap_index!(cap)) + Err(AllocError) } else { Ok(Self { inner: InnerHeap { -- 2.54.0