more typename fixes
[prop.git] / tests / qa4.cc
blob3e3e2994f5ee1ffce068522b052d28305022e268
1 // Test memory stuff
2 #include <stdio.h>
3 #include <string.h>
4 #include <assert.h>
5 #include <AD/memory/arena.h> // Arenas
6 #include <AD/memory/boundtag.h> // Boundary tag memory manager
7 #include <AD/memory/buddy.h> // Fibonacci buddy system
8 #include <AD/memory/mempool.h> // Memory pool
9 #include <AD/memory/strpool.h> // String pool
11 int main(int argc, char * argv[])
13 StringPool A; MemPool B;
14 BoundaryTag C(4096);
15 int i;
17 A["Shure"];
18 A["Waters"];
19 B[100];
21 void * core[257];
23 for (i = 0; i < 257; i++)
24 { core[i] = C[i]; memset(core[i],255,i);
26 printf("\n");
28 BoundaryTag::Statistics S = C.statistics();
29 printf("pages = %d\n", S.page_count);
30 printf("bytes allocated = %d\n", S.bytes_allocated);
31 printf("bytes available = %d\n", S.bytes_available);
32 printf("free blocks = %d\n", S.free_block_count);
34 i = 0;
35 do {
36 i = (i+8) % 257;
37 C.free(core[i]);
38 } while (i != 0);
39 printf("\n");
41 S = C.statistics();
43 printf("pages = %d\n", S.page_count);
44 printf("bytes allocated = %d\n", S.bytes_allocated);
45 printf("bytes available = %d\n", S.bytes_available);
46 printf("free blocks = %d\n", S.free_block_count);
48 // Arena arena(100);
50 // double * x = arena();
51 // double * y = arena();
53 // arena.free(x); arena.free(y);
55 char block[70*1024];
56 Buddy buddy(block, sizeof(block));
58 for (i = 0; i < 257; i++)
59 { core[i] = buddy[i]; memset(core[i],255,i); }
60 printf("\n");
62 i = 0;
63 do {
64 i = (i+8) % 257;
65 buddy.free(core[i]);
66 } while (i != 0);
67 printf("\n");
70 printf("OK\n");
71 return 0;