1#include <stdio.h>
2#include <unistd.h>
3
4#define MAX 3000
5
6// At one time, this was causing a seg fault within Valgrind -- it was when
7// extending the brk segment onto a new page.  Fixed in vg_syscalls.c 1.129.
8
9int main () {
10  char* ptr;
11  int i;
12
13  for (i=0; i<MAX; i++) {
14    ptr = sbrk(1);
15
16    if (ptr == (void*)-1) {
17      printf ("sbrk() failed!\n");
18      return 0;
19    }
20
21    *ptr = 0;
22  }
23
24  return 0;
25}
26