#include #include #include "dmalloc.h" #include "bmalloc.h" #define MAX 500 #define MAX2 1000 #define MAXC 2 #define TESTA #define TESTB #define TESTC #define TESTD int test1(void) { #define MAXK 100 int i; void *wow[MAXK]; for(i=0; i=0; i-=2) free(wow[i]); return 0; } int test2(void) { #define MAXS 10 #define MAXS1 0 int i; void *ptr[MAXS]; for(i=MAXS1; i< MAXS; i++) { printf("%d malloc(%d)\n", i, i*55); ptr[i] = malloc (i*55); } for(i=MAXS1; i< MAXS; i++) { void *tmp; printf("%d realloc(%d)\n", i, i*155); tmp=realloc(ptr[i], i*155); if(tmp) ptr[i] = tmp; } for(i=MAXS1; i< MAXS; i++) { if(ptr[i]) { printf("%d free(%d)\n", i, i*155); free(ptr[i]); } } return 0; } int test3(void) { int i; void *ptr[MAXC]; printf("This is test C:\n"); for(i=0; i< MAXC; i++) { printf("%d malloc(100)\n", i+1); ptr[i] = malloc(100); printf(" ...returned %p\n", ptr[i]); } for(i=0; i< MAXC; i++) { printf("%d free()\n", i+1); if(ptr[i]) free(ptr[i]); } printf("End of test C:\n"); return 0; } int test4(void) { int i; int memory = 0; void *pointers[MAX]; printf("This is test I:\n"); for(i=0; i