added some test results
[tridge/junkcode.git] / alloc.c
1 #include <stdio.h>
2 #include <malloc.h>
3
4 static int sum;
5
6 char *xmalloc(int size)
7 {
8         char *ret;
9         sum += size;
10         ret = malloc(size);
11         if (!ret) {
12                 fprintf(stderr,"out of memory\n");
13                 exit(1);
14         }
15         memset(ret, 1, size);
16         return ret;
17 }
18
19 main(int argc, char *argv[])
20 {
21         int n = atoi(argv[1]);
22         int i;
23         
24         for (i=0;i<n;i++) {
25                 xmalloc(56);
26                 xmalloc(9);
27         }
28         
29         printf("allocated %d bytes\n", sum);
30         sleep(20);
31 }