/* ** Test program for memory manager. ** Some Assembly Required - BYTE Magazine ** Rick Grehan */ #include #include /* ** Defines */ #define NUMPTRS 1000 /* Number of pointer nodes */ /* ** Global storage. */ unsigned int numparas; /* Number of paragraphs in heap */ unsigned int memhandle[5]; /* Array of handles */ unsigned int hseg; /* Segment */ /* ** Externals */ extern unsigned int initmem(); extern unsigned int gethandle(); extern unsigned int freehandle(); extern unsigned int lockhandle(); extern unsigned int unlockhandle(); extern unsigned int handtoseg(); main() { long i; unsigned int amtoget; char huge *chptr1; char huge *chptr2; /* ** Initialize the memory manager. */ numparas=initmem(NUMPTRS); printf("Heap initialized with %u paragraphs\n",numparas); amtoget=numparas/5; printf("Grabbing in chunks of %u\n",amtoget); /* ** Allocate some memory. */ for(i=0;i<5;i++) { memhandle[i]=gethandle(amtoget); printf("Got memory handle %u\n",memhandle[i]); } /* ** Load up blocks 1 and 4. */ chptr1=(char huge *)MK_FP(handtoseg(memhandle[1]),0); chptr2=(char huge *)MK_FP(handtoseg(memhandle[4]),0); for(i=0;i