Skip to content
Snippets Groups Projects
Unverified Commit f46fa0d0 authored by Michael Müller's avatar Michael Müller
Browse files

Move variables into constructor

parent 6c06d4d7
No related merge requests found
......@@ -54,7 +54,13 @@ impl FreeingBumpHeapAllocator {
/// * `heap_size` - The size available to this heap instance (in bytes) for
/// allocating memory.
///
pub fn new(mut ptr_offset: usize, heap_size: usize, heap: MemoryRef) -> Self {
pub fn new(heap: MemoryRef) -> Self {
let current_size: Bytes = m.current_size().into();
let current_size = current_size.0;
let used_size = m.used_size().0;
let heap_size = current_size - used_size;
let ptr_offset = used_size;
let padding = ptr_offset % ALIGNMENT;
if padding != 0 {
ptr_offset += ALIGNMENT - padding;
......
......@@ -57,14 +57,9 @@ struct FunctionExecutor<'e, E: Externalities<Blake2Hasher> + 'e> {
impl<'e, E: Externalities<Blake2Hasher>> FunctionExecutor<'e, E> {
fn new(m: MemoryRef, t: Option<TableRef>, e: &'e mut E) -> Result<Self> {
let current_size: Bytes = m.current_size().into();
let current_size = current_size.0;
let used_size = m.used_size().0;
let heap_size = current_size - used_size;
Ok(FunctionExecutor {
sandbox_store: sandbox::Store::new(),
heap: allocator::FreeingBumpHeapAllocator::new(used_size, heap_size, m.clone()),
heap: allocator::FreeingBumpHeapAllocator::new(m.clone()),
memory: m,
table: t,
ext: e,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment