Borland C++ reference

farheapwalk

raw OCR

farheapwalk is used to "walk" through the far heap node by node.

Defined in header <alloc.h>

Syntax

#include <alloc.h>
int farheapwalk(struct farheapinfo *hi);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

farheapwalk assumes the heap is correct. Use farheapcheck to verify the

heap before using farheapwalk. _HEAPOKis returned with the last block
on the heap. _HEAPENDwill be returned on the next call to farheapwalk.

farheapwalk receives a pointer to a structure of type heapinfo (defined in alloc.h). For the first call to farheapwalk, set the hi.ptr field to null. farheapwalk returns with hi.ptr containing the address of the first block, hi.size holds the size of the block in bytes, hi.inuse is a flag that's set if the block is currently in use.

Return value

HEAPEMPTYis returned if there is no heap (value 1).
_HEAPOKis returned if the heapinfo block contains valid data (value 2).
_HEAPENDis returned if the end of the heap has been reached (value 5).

See also

  • heapwalk
  • #include
  • <stdio.h>
  • #include
  • <alloc.h>
  • fdefine_PTRS
  • 10
  • #defineBYTES
  • 16
  • int
  • main
  • {
  • struct
  • farheapinfo
  • hi;
  • char
  • far
  • *array[
  • NUM_PTRS
  • ];
  • int
  • i;
  • for{
  • i
  • =
  • 0;
  • i
  • <
  • NUM_PTRS;
  • i++
  • )
  • array[
  • i
  • ]
  • =
  • farmalloc
  • farfree;
  • hi.ptr
  • =
  • NULL;
  • printf;
  • printf;
  • while
  • ==
  • _HEAPOK
  • )
  • printf(
  • "%7u
  • %s\n"
  • hi.size
  • hi.in_use
  • ?
  • "used"'free"

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.