Programming Tips - My heap is being corrupted somehow, how can I locate where?

Date: 2010apr21 Language: C/C++ Product: Borland C++ 5.x Keywords: malloc, free Q. My heap is being corrupted somehow, how can I locate where? A. Sprinkle calls to heapcheck() around your code to narrow down the location. Example from the help file:
#include <malloc.h> if (heapcheck() == _HEAPCORRUPT) { printf("Heap is corrupted.\n"); } else { printf("Heap is OK.\n"); }
There is also a _heapchk() function.