Created
October 29, 2016 01:16
-
-
Save JZHeadley/e958ed1df3eb1fcf0c525b7768fa2197 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void showLeaks() { | |
| int sizeOfList = 0; | |
| int amountOfFree = 0; | |
| int numBlocks = 0; | |
| struct block_meta * nextBlock = (struct block_meta *) global_base; | |
| while (nextBlock) { | |
| numBlocks++; | |
| sizeOfList += nextBlock->size; | |
| if (nextBlock->free) { | |
| amountOfFree += nextBlock->size; | |
| } | |
| printf("Block Number %#03i\tBlock location: %p\tBlock Size: %05lu\tIt is free: %s\tMagic: %#012x\tNextBlock: %p\n" | |
| ,numBlocks | |
| ,nextBlock | |
| ,nextBlock->size | |
| ,(nextBlock->free) ? "true" : "false" | |
| ,nextBlock->magic | |
| ,nextBlock->next); | |
| nextBlock = nextBlock->next; | |
| } | |
| printf("\nTotal size of the list:\t%i\n", sizeOfList); | |
| printf("The list was %i nodes long.\n", numBlocks); | |
| printf("Amount of memory wasted by Meta_Block structs:\t%i\n", numBlocks * (int) META_SIZE); | |
| printf("Amount of free memory in list:\t%i\n", amountOfFree); | |
| printf("The amount of memory allocated to data: %i\n", (sizeOfList - amountOfFree)); | |
| printf("\n\n\n\n\n"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment