/// Create a new heap without checking for parameter validity.
/// Useful for const heap creation.
///
/// # Safety
/// `heap_base` must be aligned on a
/// `MIN_HEAP_ALIGN` boundary, `heap_size` must be a power of 2, and
/// `heap_size / 2.pow(free_lists.len()-1)` must be greater than or
/// equal to `size_of::<FreeBlock>()`.  Passing in invalid parameters
/// may do horrible things.
Create a new heap without checking for parameter validity.
Useful for const heap creation.
Create a new heap without checking for parameter validity . Useful for const heap creation .
pub const unsafe fn new_unchecked(heap_base: *mut u8, heap_size: usize) -> Self {
        // Calculate our minimum block size based on the number of free
        // lists we have available.
        let min_block_size = heap_size >> (N - 1);
        let mut free_lists: [*mut FreeBlock; N] = [core::ptr::null_mut(); N];
        // Insert the entire heap into the last free list.
        // See the documentation for `free_lists` - the last entry contains
        // the entire heap iff no memory is allocated.
        free_lists[N - 1] = heap_base as *mut FreeBlock;
        // Store all the info about our heap in our struct.
        Self {
            heap_base: heap_base,
            heap_size,
            free_lists,
            min_block_size,
            min_block_size_log2: log2(min_block_size),
        }
    }
pub const unsafe fn new_unchecked ( heap_base : * mut u8 , heap_size : usize ) -> Self { // Calculate our minimum block size based on the number of free // lists we have available. let min_block_size = heap_size >> ( N - 1 ) ; let mut free_lists : [ * mut FreeBlock ; N ] = [ core :: ptr :: null_mut ( ) ; N ] ; // Insert the entire heap into the last free list. // See the documentation for `free_lists` - the last entry contains // the entire heap iff no memory is allocated. free_lists [ N - 1 ] = heap_base as * mut FreeBlock ; // Store all the info about our heap in our struct. Self { heap_base : heap_base , heap_size , free_lists , min_block_size , min_block_size_log2 : log2 ( min_block_size ) , } }
Create a new heap without checking for parameter validity.
Create a new heap without checking for parameter validity .
heap_base
*mut u8
heap_size
usize
safety
`heap_base` must be aligned on a
`MIN_HEAP_ALIGN` boundary, `heap_size` must be a power of 2, and
`heap_size / 2.pow(free_lists.len()-1)` must be greater than or
equal to `size_of::()`.  Passing in invalid parameters
may do horrible things.
` heap_base ` must be aligned on a ` MIN_HEAP_ALIGN ` boundary ` heap_size ` must be a power of 2 and ` heap_size / 2 . pow ( free_lists . len () - 1 ) ` must be greater than or equal to ` size_of :: () ` . Passing in invalid parameters may do horrible things .