Explorar el Código

Heap allocator does not need access to heap

The bump allocator just returns the next block, no state is stored in
the heap itself.

Signed-off-by: Sean Young <sean@mess.org>
Sean Young hace 4 años
padre
commit
a36d1c31fc
Se han modificado 2 ficheros con 2 adiciones y 19 borrados
  1. 1 15
      tests/solana.rs
  2. 1 4
      tests/solana_helpers/allocator_bump.rs

+ 1 - 15
tests/solana.rs

@@ -702,20 +702,6 @@ struct SolAccountMeta {
     is_signer: bool,
 }
 
-/// Rust representation of C's SolAccountInfo
-#[derive(Debug)]
-struct SolAccountInfo {
-    key_addr: u64,
-    lamports_addr: u64,
-    data_len: u64,
-    data_addr: u64,
-    owner_addr: u64,
-    rent_epoch: u64,
-    is_signer: bool,
-    is_writable: bool,
-    executable: bool,
-}
-
 /// Rust representation of C's SolSignerSeed
 #[derive(Debug)]
 struct SolSignerSeedC {
@@ -1192,7 +1178,7 @@ impl VirtualMachine {
 
         vm.bind_syscall_context_object(
             Box::new(SyscallAllocFree {
-                allocator: Allocator::new(heap, ebpf::MM_HEAP_START),
+                allocator: Allocator::new(DEFAULT_HEAP_SIZE as u64, ebpf::MM_HEAP_START),
             }),
             None,
         )

+ 1 - 4
tests/solana_helpers/allocator_bump.rs

@@ -2,17 +2,14 @@ use std::alloc::Layout;
 
 #[derive(Debug)]
 pub struct Allocator {
-    heap: Vec<u8>,
     start: u64,
     len: u64,
     pos: u64,
 }
 
 impl Allocator {
-    pub fn new(heap: Vec<u8>, virtual_address: u64) -> Self {
-        let len = heap.len() as u64;
+    pub fn new(len: u64, virtual_address: u64) -> Self {
         Allocator {
-            heap,
             start: virtual_address,
             len,
             pos: 0,