Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <malloc.h>
    int  _heapchk( void );
    int _bheapchk( __segment seg );
    int _fheapchk( void );
    int _nheapchk( void );

Description:
    The  _heapchk functions along with  _heapset and  _heapwalk are provided
    for debugging heap related problems in programs.

    The  _heapchk functions perform a consistency check on the unallocated
    memory space or "heap".  The consistency check determines whether all
    the heap entries are valid.  Each function checks a particular heap, as
    listed below:

    _heapchk
        Depends on data model of the program

    _bheapchk
        Based heap specified by seg value;  _NULLSEG specifies all based
        heaps

    _fheapchk
        Far heap (outside the default data segment)

    _nheapchk
        Near heap (inside the default data segment)

    In a small data memory model, the  _heapchk function is equivalent to
    the  _nheapchk function; in a large data memory model, the  _heapchk
    function is equivalent to the  _fheapchk function.

Returns:
    All four functions return one of the following manifest constants which
    are defined in <malloc.h>.

    _HEAPOK
        The heap appears to be consistent.

    _HEAPEMPTY
        The heap is empty.

    _HEAPBADBEGIN
        The heap has been damaged.

    _HEAPBADNODE
        The heap contains a bad node, or is damaged.


See Also:
    _heapenable, _heapgrow Functions, _heapmin Functions, _heapset Functions, _heapshrink Functions, _heapwalk Functions

Example:
    #include <stdio.h>
    #include <malloc.h>

    void main()
      {
        char *buffer;

        buffer = (char *)malloc( 80 );
        malloc( 1024 );
        free( buffer );
        switch( _heapchk() ) {
        case _HEAPOK:
          printf( "OK - heap is good\n" );
          break;
        case _HEAPEMPTY:
          printf( "OK - heap is empty\n" );
          break;
        case _HEAPBADBEGIN:
          printf( "ERROR - heap is damaged\n" );
          break;
        case _HEAPBADNODE:
          printf( "ERROR - bad node in heap\n" );
          break;
        }
      }

Classification:
    WATCOM

Systems:
     _heapchk - All

    _fheapchk - DOS/16, Win/16, QNX/16, OS/2 1.x(all)
    _nheapchk - DOS, Win, QNX, OS/2 1.x, OS/2 1.x(MT), OS/2 2.x, NT
    _bheapchk - DOS/16, Win/16, QNX/16, OS/2 1.x(all)

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson