diff --git a/mm.c b/mm.c index a6c36ac..fe76e53 100644 --- a/mm.c +++ b/mm.c @@ -65,7 +65,7 @@ static size_t align(size_t size) { } -static struct list *free_lists[NUM_LISTS]; +static struct list free_lists[NUM_LISTS]; static size_t list_sizes[NUM_LISTS]; /* Function prototypes for internal helper routines */ @@ -153,9 +153,9 @@ int mm_init(void) initial[3] = FENCE; /* Epilogue header */ for (int i = 0; i < NUM_LISTS; i++) { - struct list *current_list = malloc(sizeof(struct list)); - list_init(current_list); - free_lists[i] = current_list; + + list_init(&free_lists[i]); + } for (int i = 0; i < NUM_LISTS; i++) { @@ -372,10 +372,10 @@ static struct list* find_list(int not_empty, size_t n_words) { for (int i = 0; i < NUM_LISTS; i++) { if ((n_words <= list_sizes[i]) || (i == (NUM_LISTS - 1))) { - if (not_empty && list_empty(free_lists[i])) { + if (not_empty && list_empty(&free_lists[i])) { continue; } - return free_lists[i]; + return &free_lists[i]; } } return NULL;