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 Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <malloc.h>
    int  _heapset( unsigned char fill_char );
    int _bheapset( __segment seg, unsigned char fill_char );
    int _fheapset( unsigned char fill_char );
    int _nheapset( unsigned char fill_char );

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

    The _heapset functions perform a consistency check on the unallocated
    memory space or "heap" just as  _heapchk does, and sets the heap's free
    entries with the fill_char value.

    Each function checks and sets a particular heap, as listed below:

    Function     Heap Filled

_heapset
    Depends on data model of the program

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

_fheapset
    Far heap (outside the default data segment)

_nheapset
    Near heap (inside the default data segment)

    In a small data memory model, the _heapset function is equivalent to the
     _nheapset function; in a large data memory model, the _heapset function
    is equivalent to the  _fheapset function.

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

    Constant     Meaning

_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.


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

    void main()
      {
        int heap_status;
        char *buffer;

        buffer = (char *)malloc( 80 );
        malloc( 1024 );
        free( buffer );
        heap_status = _heapset( 0xff );
        switch( heap_status ) {
        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:
     _heapset - All

    _fheapset - DOS/16, Windows, QNX/16, OS/2 1.x(all)
    _nheapset - DOS, Windows, Win386, Win32, QNX, OS/2 1.x, OS/2 1.x(MT),
    OS/2-32
    _bheapset - DOS/16, Windows, QNX/16, OS/2 1.x(all)

See Also:
    _heapchk, _heapenable, _heapgrow, _heapmin, _heapshrink, _heapwalk

See Also: _heapenable

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