From 750af65527bef16bfd6e8f9205331ee8a8815ae7 Mon Sep 17 00:00:00 2001 From: Edward Amsden Date: Fri, 22 Nov 2024 18:01:54 -0600 Subject: [PATCH] Add feature flag to shut off OOM checks --- rust/sword/Cargo.toml | 1 + rust/sword/src/mem.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/rust/sword/Cargo.toml b/rust/sword/Cargo.toml index 39ea853..31e9d54 100644 --- a/rust/sword/Cargo.toml +++ b/rust/sword/Cargo.toml @@ -43,3 +43,4 @@ check_junior = [] sham_hints = [] stop_for_debug = [] hint_dont = [] +no_oom_check = [] diff --git a/rust/sword/src/mem.rs b/rust/sword/src/mem.rs index b9abbbb..70174c3 100644 --- a/rust/sword/src/mem.rs +++ b/rust/sword/src/mem.rs @@ -294,6 +294,12 @@ impl NockStack { // Directionality parameters: (East/West), (Stack/Alloc), (pc: true/false) // Types of size: word (words: usize) /// Check if an allocation or pointer retrieval indicates an invalid request or an invalid state + #[cfg(feature = "no_oom_check")] + pub const fn alloc_would_oom_(&self, alloc: Allocation, words: usize) -> AllocResult<()> { + Ok(()) + } + + #[cfg(not(feature = "no_oom_check"))] pub fn alloc_would_oom_(&self, alloc: Allocation, words: usize) -> AllocResult<()> { let _memory_state = self.memory_state(Some(words)); if self.pc && !alloc.alloc_type.allowed_when_pc() {