Borland C++ reference

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

DOSUNIXWindowsANSI CC++ only
■

Remarks

If a node has been freed and farheapchecknode is called with a pointer to

the freed block, farheapchecknode can return _BADNODErather 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.

_HEAPEMPTYis returned if there is no heap (value 1).
HEAPCORRUPTis returned if the heap has been corrupted (value -1).
_BADNODEis returned if the node could not be found (value -2).
FREEENTRYis returned if the node is a free block (value 3).
USEDENTRYis 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.