4.14.11. __heapvalid()

The __heapvalid() functionperforms a consistency check on the heap. It outputs detailed information about every free block if the verbose parameter is nonzero, and only output errors otherwise.

The function outputs its results by calling the output function dprint, which must work like fprintf(). The first parameter passed to dprint is the supplied pointer param. You can pass fprintf() itself, provided you cast it to the right function pointer type. This type is defined as a typedef for convenience. It is called __heapprt. For example:

Example 4.21.  Calling __heapvalid() with fprintf()

__heapvalid((__heapprt) fprintf, stderr, 0);

If you call fprintf() on a stream that you have not already sent output to, the library calls malloc() internally to create a buffer for the stream. If this happens in the middle of a call to __heapvalid(), the heap might be corrupted. You must therefore ensure you have already sent some output to stderr. The code in Example 4.21 will cause a major failure if you have not already written to the stream.

This function is an ARM-specific library extension.


int __heapvalid(int (*dprint)( void*param, char const *format,...), void* param, int verbose);

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D