Add feature flag to shut off OOM checks

This commit is contained in:
Edward Amsden 2024-11-22 18:01:54 -06:00
parent 14124d804e
commit 750af65527
2 changed files with 7 additions and 0 deletions

View File

@ -43,3 +43,4 @@ check_junior = []
sham_hints = []
stop_for_debug = []
hint_dont = []
no_oom_check = []

View File

@ -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() {