#include #include #include int main() { int r1 = _heapchk(); printf("before any alloc: _heapchk=%d\n", r1); fflush(stdout); void *p = malloc(1024); int r2 = _heapchk(); printf("after malloc(1024): _heapchk=%d (p=%p)\n", r2, p); fflush(stdout); /* NO corruption - just test if _heapchk works */ int r3 = _heapchk(); printf("no corruption: _heapchk=%d\n", r3); fflush(stdout); free(p); int r4 = _heapchk(); printf("after free: _heapchk=%d\n", r4); fflush(stdout); return 0; }