Keil Logo


4.13 __heapvalid()

Defined in stdlib.h, the __heapvalid() function performs a consistency check on the heap.


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


__heapvalid() outputs full information about every free block if the verbose parameter is nonzero. Otherwise, it only outputs errors.
The function outputs its results by calling the output function dprint(), that 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:
__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 example code fails if you have not already written to the stream.
This function is not part of the C library standard, but the ARM® C library supports it as an extension.
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.