• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <unistd.h>
3 
4 #define MAX 20000
5 
main()6 int main () {
7   int i;
8   int inc_dec;
9   int delta;
10   intptr_t brk_stat;
11 
12   // loop to first increase, then decrease
13   for (inc_dec = 1; inc_dec >= -1; inc_dec-=2) {
14      // loop to increase(decrease) with small then big delta
15      for (delta = 1; delta <= 400; delta+=399) {
16         if (0) printf("initial brk value for inc_dec %d delta %d: %p\n",
17                inc_dec, delta, sbrk(0));
18         for (i=0; i<MAX; i++) {
19            brk_stat = (intptr_t)brk(sbrk(0) + inc_dec * delta);
20            if (brk_stat == -1) {
21               printf("brk value at failure: %p\n", sbrk(0));
22               perror ("brk() failed!\n");
23               return 0;
24            }
25         }
26         if (0) printf("resulting brk value for inc_dec %d delta %d: %p\n",
27                inc_dec, delta, sbrk(0));
28      }
29   }
30 
31   return 0;
32 }
33