9 static unsigned char* V[256];
13 static char* Alloc (void)
14 /* Allocate a random sized chunk of memory */
16 /* Determine the size */
17 unsigned char Size = (((unsigned char)rand()) & 0x7F) + 1;
20 unsigned char* P = malloc (Size);
22 /* Set the string to a defined value. We use the size, since this will
23 * also allow us to retrieve it later.
26 memset (P, Size, Size);
28 printf ("Could not allocate %u bytes\n", Size);
36 static void Free (unsigned char* P)
37 /* Check a memory block and free it */
41 /* Get the size of the block */
42 unsigned char Size = P[0];
45 for (I = 1; I < Size; ++I) {
47 printf ("Scan failed - expected %02X, got %02X\n",
59 static void FillArray (void)
60 /* Fill the array with randomly allocated memory chunks */
71 static void ShowInfo (void)
74 /* Count free blocks */
76 register struct freeblock* P = _heapfirst;
81 printf ("%04X %04X %04X %04X %04X %u\n",
82 _heaporg, _heapptr, _heapend, _heapfirst, _heaplast, Count);
87 printf ("%04X %04X %04X %04X(%u)\n",
88 (unsigned) P, P[2], P[1], P[0], P[0]);
97 static void Test1 (void)
101 for (I = 0; I < 0x80; ++I) {
110 static void Test2 (void)
124 static void Test3 (void)
138 static void Test4 (void)
157 static void Test5 (void)
189 static void Test6 (void)
215 /* Show info at start */
218 /* Remember the time */
229 /* Calculate the time and print it */
231 printf ("Time needed: %lu ticks\n", T);