_heapchk
Remonter à alloc.h - Index
Header File
malloc.h
Category
Memory Routines
Syntax
int _heapchk(void);
Description
Checks and verifies the heap.
_heapchk walks through the heap and examines each block, checking its pointers, size, and other critical attributes.
Return Value
One of the following values:
|
_HEAPBADNODE |
A corrupted heap block has been found |
|
_HEAPEMPTY |
No heap exists |
|
_HEAPOK |
The heap appears to be uncorrupted |
Example
#include <stdio.h>
#include <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( heapcheck() == _HEAPCORRUPT )
printf( "Heap is corrupted.\n" );
else
printf( "Heap is OK.\n" );
return 0;
}
Portability
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |