5 #include "../smalloc.h"
7 #include "../arch/arch.h"
10 #define MAGIC1 0xa9b1c8d2
11 #define MAGIC2 0xf0a1e9b3
14 #define MAXSMALLOC 120*1024*1024UL
15 #define LARGESMALLOC 128*1024U
19 struct flist_head list;
24 static FLIST_HEAD(list);
26 static int do_rand_allocs(void)
28 unsigned int size, nr, rounds = 0;
33 while (rounds++ < LOOPS) {
39 while (total < MAXSMALLOC) {
40 size = 8 * sizeof(struct elem) + (int) (999.0 * (rand() / (RAND_MAX + 1.0)));
43 printf("fail at %lu, size %u\n", total, size);
50 flist_add_tail(&e->list, &list);
54 printf("Got items: %u\n", nr);
56 while (!flist_empty(&list)) {
57 e = flist_entry(list.next, struct elem, list);
58 assert(e->magic1 == MAGIC1);
59 assert(e->magic2 == MAGIC2);
65 e = smalloc(LARGESMALLOC);
68 printf("failure allocating %u bytes at %lu allocated during sfree phase\n",
80 int main(int argc, char *argv[])
87 smalloc_debug(0); /* free and total blocks should match */