@@ -130,7 +130,7 @@ void *mm_malloc(size_t size)
130
130
* ((int * )(LL_ptr ) - 1 ) = size ; //mark size metadata with size
131
131
* LL_ptr_last = * LL_ptr ; //repaired linked list, even if null.
132
132
133
- mm_insert ((void * )((char * )LL_ptr + size + 8 ), (oldsize - newsize ));
133
+ mm_insert ((void * )((char * )LL_ptr + size + 8 ), (oldsize - newsize ));
134
134
135
135
returnPointer = ((char * )(LL_ptr ) + 3 );
136
136
break ;
@@ -182,7 +182,7 @@ void mm_free(void *argptr)
182
182
{
183
183
int size , csize ;
184
184
char * ptr = argptr ;
185
-
185
+
186
186
ptr = (char * )ptr - 3 ; //Puts ptr at start of pointer position (no 3byte buffer in free blocks)
187
187
size = * ((int * )ptr - 1 );
188
188
@@ -201,7 +201,7 @@ void mm_free(void *argptr)
201
201
if (* (ptr + size + 8 ) == 0 ) //the block AFTER is a free block
202
202
{
203
203
csize = * ((int * )((char * )ptr + size + 9 )); //size of the next block
204
- if (csize > 0 ) {
204
+ if (csize > 0 ) {
205
205
size = size + csize + 16 ;
206
206
}
207
207
}
@@ -246,14 +246,14 @@ void *mm_realloc(void *ptr, size_t size)
246
246
*/
247
247
int mm_check (void )
248
248
{
249
- void * next_ptr ;
250
- void * search_ptr * ;
249
+ size_t * next_ptr ;
250
+ size_t * search_ptr ;
251
251
int flag = 1 ;
252
252
int i ;
253
253
int size ;
254
- void * top_heap = mem_heap_hi ();
254
+ size_t * top_heap = mem_heap_hi ();
255
255
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/*{{{*/
257
257
next_ptr = CLASSES [i ];
258
258
if (next_ptr == NULL )
259
259
break ;
@@ -360,7 +360,7 @@ int mm_insert(void* location, int size) {
360
360
if (next_ptr == NULL ) {
361
361
flag = !flag ;
362
362
if (last_ptr == NULL ) //list is empty, insert at beginning
363
- CLASSES [i ] = location ;
363
+ CLASSES [i ] = (( char * ) location + 5 ) ;
364
364
else { //insert at end of list
365
365
next_ptr = ((char * )location + 5 );
366
366
* ((char * )location + 5 ) = NULL ;
@@ -377,7 +377,7 @@ int mm_insert(void* location, int size) {
377
377
* ((char * )location + 5 ) = (size_t * )next_ptr ;
378
378
}
379
379
} else { //size is not appropriate, need to try next link
380
- last_ptr = next_ptr ;
380
+ last_ptr = next_ptr ;
381
381
next_ptr = * (size_t * )next_ptr ;
382
382
}
383
383
}
0 commit comments