Skip to main content

gemachain_bpf_loader_program/
alloc.rs

1use std::{alloc::Layout, fmt};
2
3/// Based loosely on the unstable std::alloc::Alloc trait
4pub trait Alloc {
5    fn alloc(&mut self, layout: Layout) -> Result<u64, AllocErr>;
6    fn dealloc(&mut self, addr: u64, layout: Layout);
7}
8
9#[derive(Clone, PartialEq, Eq, Debug)]
10pub struct AllocErr;
11
12impl fmt::Display for AllocErr {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        f.write_str("Error: Memory allocation failed")
15    }
16}