perform a consistency check on a heap
#include <malloc.h> int _heapset( unsigned char fill_char ); int _bheapset( __segment seg, unsigned char fill_char ); int _fheapset( unsigned char fill_char ); int _nheapset( unsigned char fill_char );
The _heapset() functions, along with _heapchk() and _heapwalk() are provided for debugging heap-related problems in programs.
The _heapset() functions perform a consistency check on the unallocated memory space or "heap", just as _heapchk() does, and sets the heap's free entries with the fill_char value.
Each function checks and sets a particular heap, as listed below:
In a small data memory model, _heapset() is equivalent to _nheapset(); in a large data memory model, _heapset() is equivalent to _fheapset().
One of the following manifest constants, which are defined in <malloc.h>:
#include <stdio.h> #include <malloc.h> void main() { int heap_status; char *buffer; buffer = (char *)malloc( 80 ); malloc( 1024 ); free( buffer ); heap_status = _heapset( 0xff ); switch( heap_status ) { case _HEAPOK: printf( "OK - heap is good\n" ); break; case _HEAPEMPTY: printf( "OK - heap is empty\n" ); break; case _HEAPBADBEGIN: printf( "ERROR - heap is damaged\n" ); break; case _HEAPBADNODE: printf( "ERROR - bad node in heap\n" ); break; } }
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
_heapchk(), _heapenable(), _heapgrow(), _heapmin(), _heapshrink(), _heapwalk()