tasm_lib/rust_shadowing_helper_functions/
dyn_malloc.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::collections::HashMap;

use triton_vm::prelude::*;

use crate::empty_stack;
use crate::memory::dyn_malloc::DynMalloc;
use crate::traits::function::Function;

/// Return a pointer to the next free page of memory, and update the dyn malloc
/// state accordingly.
pub fn dynamic_allocator(memory: &mut HashMap<BFieldElement, BFieldElement>) -> BFieldElement {
    let mut init_stack = empty_stack();
    DynMalloc.rust_shadow(&mut init_stack, memory);
    init_stack.pop().unwrap()
}