nog korter ex2
[sws1-1415.git] / ass4 / mart / sws1-assignment4-s4109503-s4202015 / exercise1.c
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 int main(void)
5 {
6 size_t s = 0;
7 char *buf, dir = 1;
8 for(size_t i = 1 << 31; i >= 1; i /= 2, free(buf))
9 dir = (buf = malloc(s += dir * i)) == NULL ? -1 : 1;
10 printf("One malloc can allocate at most %zu bytes\n", s);
11 return 0;
12 }