Skip to content

Commit 64c1e00

Browse files
author
Andrew Flockhart
committed
mm_check now compiles w/o error
1 parent 69c09f6 commit 64c1e00

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

mdriver

92 Bytes
Binary file not shown.

mm.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void *mm_malloc(size_t size)
130130
*((int*)(LL_ptr) - 1) = size; //mark size metadata with size
131131
*LL_ptr_last = *LL_ptr; //repaired linked list, even if null.
132132

133-
mm_insert((void*)((char*)LL_ptr + size + 8), (oldsize - newsize));
133+
mm_insert((void*)((char*)LL_ptr + size + 8), (oldsize - newsize));
134134

135135
returnPointer = ((char*)(LL_ptr) + 3);
136136
break;
@@ -182,7 +182,7 @@ void mm_free(void *argptr)
182182
{
183183
int size, csize;
184184
char* ptr = argptr;
185-
185+
186186
ptr = (char*)ptr - 3; //Puts ptr at start of pointer position (no 3byte buffer in free blocks)
187187
size = *((int*)ptr - 1);
188188

@@ -201,7 +201,7 @@ void mm_free(void *argptr)
201201
if(*(ptr + size + 8) == 0) //the block AFTER is a free block
202202
{
203203
csize = *((int*)((char*)ptr + size + 9)); //size of the next block
204-
if (csize > 0) {
204+
if (csize > 0) {
205205
size = size + csize + 16;
206206
}
207207
}
@@ -246,14 +246,14 @@ void *mm_realloc(void *ptr, size_t size)
246246
*/
247247
int mm_check(void)
248248
{
249-
void* next_ptr;
250-
void* search_ptr*;
249+
size_t* next_ptr;
250+
size_t* search_ptr;
251251
int flag = 1;
252252
int i;
253253
int size;
254-
void* top_heap = mem_heap_hi();
254+
size_t* top_heap = mem_heap_hi();
255255

256-
for(int i = 0; i < NUM_CLASSES; i++){//traverse free lists for integrity/*{{{*/
256+
for(i = 0; i < NUM_CLASSES; i++){//traverse free lists for integrity/*{{{*/
257257
next_ptr = CLASSES[i];
258258
if (next_ptr == NULL)
259259
break;
@@ -360,7 +360,7 @@ int mm_insert(void* location, int size) {
360360
if (next_ptr == NULL) {
361361
flag = !flag;
362362
if (last_ptr == NULL) //list is empty, insert at beginning
363-
CLASSES[i] = location;
363+
CLASSES[i] = ((char*)location + 5);
364364
else { //insert at end of list
365365
next_ptr = ((char*)location + 5);
366366
*((char*)location + 5) = NULL;
@@ -377,7 +377,7 @@ int mm_insert(void* location, int size) {
377377
*((char*)location + 5) = (size_t*)next_ptr;
378378
}
379379
} else { //size is not appropriate, need to try next link
380-
last_ptr = next_ptr;
380+
last_ptr = next_ptr;
381381
next_ptr = *(size_t*)next_ptr;
382382
}
383383
}

mm.o

1.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)