KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q32442: _Heapchk() Performs Consistency Check on Heap

Article: Q32442
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 12-JUL-1988

The _heapchk() routine performs a consistency check on the heap by
examining the header information of the memory blocks in the heap.
However, it cannot detect corruption of data within the heap's nodes;
it only can detect corruption of the heap's header information.
   The _heapchk() routine checks for the following:

   1. It checks to see if any heap has been allocated at all. If not,
      _heapchk() returns _HEAPEMPTY.
   2. It checks the beginning of the heap block to see if the first
      allocation block has been corrupted; if so, it returns _HEAPBADBEGIN.
      (Note that only the header information is checked.)
   3. It scans through the far heap block, moving from node to node.
      For each node, it checks the header information to make sure it has
      not been corrupted; if so, _heapchk() returns _HEAPBADNODE.
      Note that the only kind of corruption _heapchk() can detect is an
      out-of-bounds value in the header; it cannot detect corrupted data
      within the heap block itself. If the fill value passed is not
      _HEAPSET_NOFILL, and the block is unallocated, _heapchk() fills
      memory with the fill value.
   4. If _heapchk() made it all the way through the heap (i.e., it checked
      the headers for all nodes), it returns _HEAPOK.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.