tasm_lib/rust_shadowing_helper_functions/
dyn_malloc.rs

1use std::collections::HashMap;
2
3use triton_vm::prelude::*;
4
5use crate::empty_stack;
6use crate::memory::dyn_malloc::DynMalloc;
7use crate::traits::function::Function;
8
9/// Return a pointer to the next free page of memory, and update the dyn malloc
10/// state accordingly.
11pub fn dynamic_allocator(memory: &mut HashMap<BFieldElement, BFieldElement>) -> BFieldElement {
12    let mut init_stack = empty_stack();
13    DynMalloc.rust_shadow(&mut init_stack, memory);
14    init_stack.pop().unwrap()
15}