Header File
alloc.h
Category
Memory Routines
Prototype
int heapcheck(void);
Description
Checks and verifies the heap.
heapcheck walks through the heap and examines each block, checking its pointers, size, and other critical attributes.
Return Value
The return value is less than 0 for an error and greater than 0 for success. The return values and their meaning are as follows:
_HEAPCORRUPT |
Heap has been corrupted |
_HEAPEMPTY |
No heap |
_HEAPOK |
Heap is verified |
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++ |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|