// // mm_init - Initialize the memory manager // int mm_init(void) { CL_init(&free_list); // Create empty heap if ((heap_listp = mem_sbrk(4*WSIZE)) == (void *)-1){ return -1; } //alignment padding PUT(heap_listp, 0); // prologue header PUT(heap_listp + (WSIZE), PACK(DSIZE, 1)); //prologue footer PUT(heap_listp + (DSIZE), PACK(DSIZE, 1)); //epilogue header PUT(heap_listp + (3*WSIZE), PACK(0, 1)); heap_listp += (DSIZE); //extend empty heap with free block of CHUNKSIZE byes if (extend_heap(CHUNKSIZE/WSIZE) == NULL){ return -1; } return 0; }
// // mm_init - Initialize the memory manager // int mm_init(void) { CL_init(&free_list); if ((heap_listp = mem_sbrk(4*WSIZE)) == (void *)-1) { // heap start return -1; } PUT(heap_listp, 0); PUT(heap_listp + (WSIZE), PACK(DSIZE, 1)); PUT(heap_listp + (DSIZE), PACK(DSIZE, 1)); PUT(heap_listp + (3 * WSIZE), PACK(0, 1)); heap_listp += (DSIZE); if (extend_heap(CHUNKSIZE / WSIZE) == NULL) { return -1; } return 0; }