Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Allocate 4 quarters.
- void* q1 = malloc((HEAP_SIZE / 4) - 24);
- void* q2 = malloc((HEAP_SIZE / 4) - 24);
- void* q3 = malloc((HEAP_SIZE / 4) - 24);
- void* q4 = malloc((HEAP_SIZE / 4) - 24);
- //Free the middle two.
- free(q2);
- free(q3);
- //Malloc the middle two quarters out again.
- void* center = malloc((HEAP_SIZE / 2) - 48);
- center++;
- int wantedMallocCount = 5;
- if(wantedMallocCount != mCount){
- printf("Malloc was called %ld times, but we want %d calls.", mCount, wantedMallocCount);
- }
- free(q1);
- free(q4);
- if(fCount != 4){
- printf("Something wrong with free. Free was called 4 times, but count was %ld", fCount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement