farheapchecknode
raw OCR
Checks and verifies a single node on the far heap.
Defined in header <alloc.h>
Syntax
#include <alloc.h>
int farheapchecknode(void *node);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
If a node has been freed and farheapchecknode is called with a pointer to
| the freed block, farheapchecknode can return _BADNODE | rather than |
| the expected _FREEENTRY. | This is because adjacent free blocks on the |
heap are merged, and the block in question no longer exists.
Return value
The return value is less than zero for an error and greater than zero for success.
| _HEAPEMPTY | is returned if there is no heap (value 1). |
| HEAPCORRUPT | is returned if the heap has been corrupted (value -1). |
| _BADNODE | is returned if the node could not be found (value -2). |
| FREEENTRY | is returned if the node is a free block (value 3). |
| USEDENTRY | is returned if the node is a used block (value 4). |
See also
Example
#include <stdio.h>
#include <alloc.h>
Mefine NUM_PTRS 10
#define NUM_BYTES 16
int main (void)
{
char far *array [ NUM_PTRS ];
int i;
for( i = 0; i < NUM_PTRS; i++ )
array [ i ] = (char far *) fannalloc( NUM_BYTES
fori i = 0; i < NUM_PTRS; i += 2 )
farfree( array [ i ] );
for( i = 0; i < NUM_PTRS; i++ ) {
printf( "Node %2d ", i );
switch ( farheapchecknode! array[ i ] )) {
case _HEAPEMPTY:
printfC'No heap.\n" ) ;
break;
case _HEAPCORRUPT:
printf ("Heap corrupt.\n" ) ;
break;
case _BADNODE:
printf ("Bad node.\n" );
break;
case _FREEENTRY:
printf ("Free entry.\n" );
break;
case _USEDENTRY:
printf ("Used entry.\n" );
break;
default:
printf ("Unknown return code.\n");
break;
}
}
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/farheapchecknode/
· short form /3.1/farheapchecknode/