L6 due April 16. *40 points for performance *20 points for correctness *5 points for style Get the correctness points this week. *Get a feel for how hard the lab is. *You'll probably need the time (starting a couple days before is BAD) How to get the correctness points: We provide mm-helper.c which contains the code from the book. -malloc works -free works (with coalescing) -heapchecking doesn't work -realloc doesn't work Implement a dumb version of realloc -malloc new block, memcpy, free old block, return new block Implement heap checking -have to add a request id field to each allocated block (tricky) -hint: need padding to maintain 8 byte alignment of user pointer -in the book's code bp always the same as the user pointer --------------------------------- |size+a| payload.. |footer| --------------------------------- ^ | bp -the 4 bytes immediately before bp contain size of payload -3 lsb of size unused (because of alignment) -first bit indicates of the block is alloced or not -Need to change block layout to look like this: ---------------------------------------- | id |size+a| payload.. |footer| ---------------------------------------- ^ | bp -This changes how the implicit list has to be traversed -but size is at same place relative to bp OR ---------------------------------------- |size+a| id | payload.. |footer| ---------------------------------------- ^ | bp -All accesses to what was size now access id -but can be clever and make size 4 bytes larger -could even make bp point to id.. -most code would just work -Once malloc, free, and realloc work with the id field, write heapcheck -iterate over the whole heap and print out allocated blocks -need to read the id field.. That's it for correctness. Hints: -Remember that pointer arithematic behaves differently depending on type of pointer -Consider using structs/unions to eliminate some messy pointer code -Get things working with the short trace file first: ./mdriver -f short1-bal.rep