Name
_fheapwalk, _nheapwalk - Returns the address of the next
heap entry structure.
Syntax
#include <malloc.h>
int _fheapwalk(farentry)
struct _heapinfo *farentry;
struct _heapinfo
{
int far *_pentry; /* Heap entry pointer */
size_t _size; /* Size of heap entry */
int _useflag; /* Entry in-use flag */
} *entry;
int _nheapwalk(nearentry)
struct _heapinfo *nearentry;
Description
The _fheapwalk and _nheapwalk routines help debug heap-
related problems in programs.
The _heapwalk routine walks through the heap, one entry per
call, returning a pointer to a _heapinfo structure that
contains information about the next heap entry. The
structure is defined in malloc.h.
Calls to both routines return _HEAPOK and set the _useflag
field to either FREEENTRY or _USEDENTRY (defined in
malloc.h). To obtain information about the first entry in
the heap, pass a pointer to a heapinfo structure whose
_pentry field is NULL.
In large data models (that is, compact- and large-model
programs), use _fheapwalk. In small data models (small- and
medium-model programs), use _nheapwalk.
These routines walk through the heap as shown in the
following list:
Function Heap Walked
_fheapwalk Depends on data model of program
_nheapwalk Near heap (inside default data segment)
Return Value
All three routines return one of the following manifest
constants (defined in malloc.h):
Constant Meaning
_HEAPOK The heap is all right so far, and the
_heapinfo structure contains
information about the next entry.
_HEAPEMPTY The heap is not initialized.
_HEAPBADPTR The _pentry field of the entry
structure does not contain a valid
pointer into the heap.
_HEAPBADBEGIN The initial header information cannot
be found or is invalid.
_HEAPBADNODE Bad node found or the heap is damaged.
_HEAPEND End of heap reached successfully.
See Also
_fheapchk(DOS)
(printed 6/18/89)