www.pudn.com > 内存管理 胡一刀 .rar > TEST.C
//测试函数 #include "memory.h" #include#include void main() { int i; char *ch[200]; int randnum; struct list *tmplist; //my_test_para mytest[N]; //初始话一整块全为空闲区 mymemory.memorybase = memoryarray; mymemory.memorysize = TOTALMEMORY; mymemory.myalloclist = NULL; mymemory.myfreelist = (struct list *)memoryarray; mymemory.myfreelist->size = TOTALMEMORY - sizeof(struct list *); mymemory.myfreelist->next = NULL; mymemory.myfreelist->pre = NULL; //初始化完毕 printf("test begin...\n"); srand((unsigned)time(NULL)); for(i=0;i<200;i++) { randnum = rand()%500+1; ch[i] = myalloc(randnum); randnum = rand()%2; if(randnum==1) { randnum = rand()%(i+1); myfree(ch[randnum]); } } getch(); }