smash_test.c 408 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Test that overwrite error detection works reasonably.
  3. */
  4. #define GC_DEBUG
  5. #include "gc.h"
  6. #include <stdio.h>
  7. #define COUNT 7000
  8. #define SIZE 40
  9. char * A[COUNT];
  10. int main(void)
  11. {
  12. int i;
  13. char *p;
  14. GC_INIT();
  15. for (i = 0; i < COUNT; ++i) {
  16. A[i] = p = (char*)GC_MALLOC(SIZE);
  17. if (i%3000 == 0) GC_gcollect();
  18. if (i%5678 == 0 && p != 0) p[SIZE + i/2000] = 42;
  19. }
  20. return 0;
  21. }