malloc

IT/CS

[CS] malloc-lab 구현 - 명시적 가용 리스트

malloc-lab - 명시적 가용 리스트 explicit free list 방식 자세한 것은 이전의 [[malloc-lab 구현 - 묵시적 가용 리스트]] 참고 상수 및 매크로 선언 #define MINIMUM 16 #define PREC_FREEP(bp) (*(void **)(bp)) #define SUCC_FREEP(bp) (*(void **)(bp + WSIZE)) static char *free_listp = NULL; putFreeBlock() 새 free 블록을 free list의 처음에 추가한다(LIFO). 포인터 free_listp는 free list의 첫 주소를 가리키므로, free_listp가 가리키는 free list 안의 블록과 PRED, SUCC 링크를 진행한다. void put..

IT/CS

[CS] malloc-lab 구현 - 묵시적 가용 리스트

malloc-lab - 묵시적 가용 리스트 implicit free list 방식 mm_init() int mm_init(void) { if ((heap_listp = mem_sbrk(4 * WSIZE)) == (void *)-1) return -1; PUT(heap_listp, 0); PUT(heap_listp + (1 * WSIZE), PACK(DSIZE, 1)); PUT(heap_listp + (2 * WSIZE), PACK(DSIZE, 1)); PUT(heap_listp + (3 * WSIZE), PACK(0, 1)); heap_listp += (2 * WSIZE); prev_p = heap_listp; if (extend_heap(CHUNKSIZE / WSIZE) == NULL) return -..

KimCookieYa
'malloc' 태그의 글 목록