smash_test.c 401 Bytes
Newer Older
1 2 3 4
/*
 * Test that overwrite error detection works reasonably.
 */
#define GC_DEBUG
5 6
#include "gc.h"

7 8 9 10 11 12 13
#include <stdio.h>

#define COUNT 7000
#define SIZE  40

char * A[COUNT];

14
int main(void)
15
{
16 17
  int i;
  char *p;
18

19
  GC_INIT();
20

21 22
  for (i = 0; i < COUNT; ++i) {
     A[i] = p = GC_MALLOC(SIZE);
23

24 25 26 27
     if (i%3000 == 0) GC_gcollect();
     if (i%5678 == 0 && p != 0) p[SIZE + i/2000] = 42;
  }
  return 0;
28
}