Heap Check

Heap Check - • There is enough information in the headers...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Heap Check You can implement also a heapCheck function that checks for the sanity of the heap and prints the free and allocated blocks. You can call it during debugging before and after suspicious free/malloc calls. Starting from the header at the beginning of the heap, and follow the headers. checkHeap iterates over all free and allocated blocks. To get around gaps in the heap, you can store the correct size of the gaps in the fence posts around the gaps.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Heap Check
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • There is enough information in the headers to iterate over the end of the heap. • Verify that the sizes and flags in header and footer match. • Print also the blocks. Add an extra flag value to differentiate Gaps in the heap from allocated and free blocks. • Also you may write a function printFreeBlocks() that iterates over all lists and Heap Check Start of Heap End of Heap Footer4/Hdr5 Footer3/Hdr4 Footer2/Hdr3 Footer1/Hdr2 Footer0/Hdr1 Gap...
View Full Document

Page1 / 3

Heap Check - • There is enough information in the headers...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online