33 lines
811 B
C
33 lines
811 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include "memory_manager.h"
|
|
|
|
#define MY_HEAP_SIZE 100
|
|
|
|
int main()
|
|
{
|
|
char my_heap[MY_HEAP_SIZE];
|
|
mmInit(my_heap, MY_HEAP_SIZE);
|
|
|
|
printf("TC4: Large allocation should fail\n");
|
|
printf("1 -- Available Memory: %d, Alloc Memory: %d, Fragment Count: %d\n", get_remaining_space(), get_allocated_space(), get_fragment_count());
|
|
|
|
// Allocate 10 bytes
|
|
// shouldn't fail
|
|
char* ptr1 = mymalloc_ff(200);
|
|
if(ptr1 != NULL) {
|
|
printf("ptr1 - mymalloc_ff(10) succeeded\n");
|
|
myfree(ptr1);
|
|
}
|
|
|
|
printf("2 -- Available Memory: %d, Alloc Memory: %d, Fragment Count: %d\n", get_remaining_space(), get_allocated_space(), get_fragment_count());
|
|
|
|
printf("Total successful mallocs: %d\n", get_mymalloc_count());
|
|
mmDestroy();
|
|
|
|
return 0;
|
|
}
|