pub fn new(m: Memory<'heap>) -> Heap<'heap> {
        // total heap = pool + color_map, and pool is just color_map_size * blocks_per_colormap_byte * block_size
        // so color_map_size = heap size / (1 + bpm * bs)
        let divisor = 1 + BLOCKS_PER_COLORMAP_BYTE * BLOCK_SIZE_BYTES;
        let color_map_size = div_ceil(m.len(), divisor);
        let pool_size = floor_to(m.len() - color_map_size, BLOCK_SIZE_BYTES);
        let len = m.len();
        let (pool_data, color_data) = m.split_at(len - color_map_size);
        let blocks = pool_size / BLOCK_SIZE_BYTES;

        // all of memory is free.
        let pool = pool_data.split_at(pool_size).0;
        Heap {
            start: pool.start(),
            end: pool.end(),
            blocks,
            color_map: ColorMap::new(color_data),
            free_list: FreeList::new(pool),
            current_color: Color::Blue,
            phase: Phase::QUIET,
            check_start: ptr::null(),
            check_end: ptr::null(),
        }
    }
/// Create a new heap out of a mutable chunk of memory.
Create a new heap out of a mutable chunk of memory.
Create a new heap out of a mutable chunk of memory .
pub fn new(m: Memory<'heap>) -> Heap<'heap> {
        // total heap = pool + color_map, and pool is just color_map_size * blocks_per_colormap_byte * block_size
        // so color_map_size = heap size / (1 + bpm * bs)
        let divisor = 1 + BLOCKS_PER_COLORMAP_BYTE * BLOCK_SIZE_BYTES;
        let color_map_size = div_ceil(m.len(), divisor);
        let pool_size = floor_to(m.len() - color_map_size, BLOCK_SIZE_BYTES);
        let len = m.len();
        let (pool_data, color_data) = m.split_at(len - color_map_size);
        let blocks = pool_size / BLOCK_SIZE_BYTES;
        // all of memory is free.
        let pool = pool_data.split_at(pool_size).0;
        Heap {
            start: pool.start(),
            end: pool.end(),
            blocks,
            color_map: ColorMap::new(color_data),
            free_list: FreeList::new(pool),
            current_color: Color::Blue,
            phase: Phase::QUIET,
            check_start: ptr::null(),
            check_end: ptr::null(),
        }
    }
pub fn new ( m : Memory < ' heap > ) -> Heap < ' heap > { // total heap = pool + color_map, and pool is just color_map_size * blocks_per_colormap_byte * block_size // so color_map_size = heap size / (1 + bpm * bs) let divisor = 1 + BLOCKS_PER_COLORMAP_BYTE * BLOCK_SIZE_BYTES ; let color_map_size = div_ceil ( m . len ( ) , divisor ) ; let pool_size = floor_to ( m . len ( ) - color_map_size , BLOCK_SIZE_BYTES ) ; let len = m . len ( ) ; let ( pool_data , color_data ) = m . split_at ( len - color_map_size ) ; let blocks = pool_size / BLOCK_SIZE_BYTES ; // all of memory is free. let pool = pool_data . split_at ( pool_size ) . 0 ; Heap { start : pool . start ( ) , end : pool . end ( ) , blocks , color_map : ColorMap :: new ( color_data ) , free_list : FreeList :: new ( pool ) , current_color : Color :: Blue , phase : Phase :: QUIET , check_start : ptr :: null ( ) , check_end : ptr :: null ( ) , } }
Create a new heap out of a mutable chunk of memory.
Create a new heap out of a mutable chunk of memory .
m
Memory<'heap>
m
Memory<'heap>