Hardware Reference
In-Depth Information
free(buffer2);
free(buffer1);
}
ATS_PrintTestStatus("Repeated allocation and deallocation preserves free memory",
startMemory == ATS_GetFreeMemory());
}
// TODO MM Currently fails as __brkval is not increased, but the size of the free list is...
// Therefore looks as if the total amount of free memory increases (i.e. negative memory leak)!
void testReallocatingSmallerPreservesFreeMemory() {
int startMemory = ATS_GetFreeMemory();
// Allocate one byte more than the space taken up by a free list node
void* buffer = malloc(5);
buffer = realloc(buffer, 1);
free(buffer);
ATS_PrintTestStatus("Reallocating smaller preserves free memory",
startMemory == ATS_GetFreeMemory());
}
void testReallocatingLargerPreservesFreeMemory() {
int startMemory = ATS_GetFreeMemory();
void* buffer = malloc(1);
buffer = realloc(buffer, 5);
free(buffer);
ATS_PrintTestStatus("Reallocating larger preserves free memory",
startMemory == ATS_GetFreeMemory());
}
void testAllocatingAndDeallocatingSmallerPreservesFreeMemory() {
int startMemory = ATS_GetFreeMemory();
// Allocate one byte more than the space taken up by a free list node
void* buffer = malloc(5);
free(buffer);
buffer = malloc(1);
free(buffer);
ATS_PrintTestStatus("Allocating and deallocating smaller preserves free memory",
startMemory == ATS_GetFreeMemory());
}
void testReallocatingRepeatedlyLargerPreservesFreeMemory() {
int startMemory = ATS_GetFreeMemory();
 
Search WWH ::




Custom Search