kernel/src/allocator/allocator.c
void create_heap(heap_t * heap, uint32_t start) {
    // first we create the initial region, this is the "wilderness" chunk
    // the heap starts as just one big chunk of allocatable memory
    node_t * init_region = (node_t *)start;
    init_region->hole = 1;
    init_region->size = (HEAP_INIT_SIZE) - sizeof(node_t) - sizeof(footer_t);

    create_foot(init_region);  // create a foot (size must be defined)

    // now we add the region to the correct bin and setup the heap struct
    add_node(heap->bins[get_bin_index(init_region->size)], init_region);

    heap->start = start;
    heap->end = start + HEAP_INIT_SIZE;

#ifdef MEM_DEBUG
    heap->bytes_allocated = 0;
#endif
}
// ========================================================
// this function initializes a new heap structure, provided
// an empty heap struct, and a place to start the heap
//
// NOTE: this function uses HEAP_INIT_SIZE to determine
// how large the heap is so make sure the same constant
// is used when allocating memory for your heap!
// ========================================================
this function initializes a new heap structure, provided
an empty heap struct, and a place to start the heap

this function uses HEAP_INIT_SIZE to determine
how large the heap is so make sure the same constant
is used when allocating memory for your heap!
this function initializes a new heap structure provided an empty heap struct and a place to start the heap this function uses HEAP_INIT_SIZE to determine how large the heap is so make sure the same constant is used when allocating memory for your heap!
void create_heap(heap_t * heap, uint32_t start) {
    node_t * init_region = (node_t *)start;
    init_region->hole = 1;
    init_region->size = (HEAP_INIT_SIZE) - sizeof(node_t) - sizeof(footer_t);
    create_foot(init_region);  
    add_node(heap->bins[get_bin_index(init_region->size)], init_region);
    heap->start = start;
    heap->end = start + HEAP_INIT_SIZE;
#ifdef MEM_DEBUG
    heap->bytes_allocated = 0;
#endif
}
void create_heap ( heap_t * heap , uint32_t start ) { node_t * init_region = ( node_t * ) start ; init_region -> hole = 1 ; init_region -> size = ( HEAP_INIT_SIZE ) - sizeof ( node_t ) - sizeof ( footer_t ) ; create_foot ( init_region ) ; add_node ( heap -> bins [ get_bin_index ( init_region -> size ) ] , init_region ) ; heap -> start = start ; heap -> end = start + HEAP_INIT_SIZE ; #ifdef MEM_DEBUG heap -> bytes_allocated = 0 ; #endif }
this function initializes a new heap structure, provided
an empty heap struct, and a place to start the heap
this function initializes a new heap structure provided an empty heap struct and a place to start the heap
// first we create the initial region, this is the "wilderness" chunk // the heap starts as just one big chunk of allocatable memory // create a foot (size must be defined) // now we add the region to the correct bin and setup the heap struct