heapcheck
raw OCR
Checks and verifies the heap.
Defined in header <alloc.h>
Syntax
#include <alloc.h>
int heapcheck(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
heapcheck walks through the heap and examines each block checking its pointers, size, and other critical attributes. In the large data models, heapcheck maps to farheapcheck.
Return value
The return value is less than zero for an error and greater than zero for success. The return values and their meaning is as follows:
| _HEAPEMPTY | no heap (value 1). |
| _HEAPOK | heap is verified (value 2). |
| _HEAPCORRUPT | heap has been corrupted (value -1). |
See also
Example
#include <stdio.h>
finclude <alloc.h>
#define NUM_PTRS 10
#define NUM_BYTES 16
int main(void)
{
char *array[ NUM_PTRS ];
int i;
for( i = 0; i < NUM_PTRS; i++ )
array[ i ] = (char *) malloc( NUM_BYTES
for( i = 0; i < NUM_PTRS; i+= 2 )
free( array[ i ] );
if( heapcheck0 == _HEAPCORRUPT )
printf( "Heap is corrupted.\n" ) ;
else
printf( "Heap is OK.\n" );
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/alloc.h/heapcheck/
· short form /3.1/heapcheck/