INF: How _fheapwalk() Checks the Heap

ID Number: Q33366

5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

The _fheapwalk() function traverses those parts of the far heap that

have been allocated either by fmalloc() or by a system call. This

process is done by covering one such allocation per call of

_fheapwalk(), independent of the size of the block allocated.

On each call of _fheapwalk(), a manifest-constant int is returned as

documented on page 357 of the "Microsoft C Optimizing Compiler

Run-Time Reference Library" for version 5.1.

Also, a pointer to a structure is returned containing information

about the block allocated, which also is documented on page 356 of the

C run-time reference manual.

One undocumented feature of the function is that it does not return

the actual memory address of an _fmalloc()ed block, only the block's

size.

As a result, it is incorrect to assume that the memory location of the

beginning of a block can be determined by adding up the values of the

blocks already allocated. The header information in each such block is

omitted from the structure whose pointer is returned by _fmalloc(). In

particular, the size of the header is omitted from the structure.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00