heapfillfree
raw OCR
Fills the free blocks on the heap with a constant value.
Defined in header <alloc.h>
Syntax
#include <alloc.h>
int heapfillfree(unsigned int fillvalue);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
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 accurate (value 2). |
| _HEAPCORRUPT | heap has been corrupted (value -1). |
See also
Example
#include <stdio.h>
iinclude <alloc.h>
iinclude <mem.h>
idefine NUM_PTRS 10
tdefine NUM_BYTES 16
int main(void)
{
char *array[ NUM_PTRS
int i, res;
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( heapfillfree ( 1 ) < 0 ) {
printf( "Heap corrupted.\n" );
return 1;
}
for( i = 1; i < NUM_PTRS; i += 2 )
memset( array [ i ], 0, NUM_BYTES );
res = heapcheckfree( 1 );
if( res < 0 )
switch ( res ) {
case _HEAPCORRUPT :
printf( "Heap corrupted.\n" );
return 1;
case _BADVALUE:
printf( "Bad value in free space.\n" );
return 1;
default:
printf( "Unknown error.\n" );
return 1;
}
printf( "Test successful. \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/heapfillfree/
· short form /3.1/heapfillfree/