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 _heapenable( int enabled );

Description:
    The _heapenable function is used to control attempts by the heap
    allocation manager to request more memory from the operating system's
    memory pool.  If enabled is 0 then all further allocations which would
    normally go to the operating system for more memory will instead fail
    and return NULL.  If enabled is 1 then requests for more memory from the
    operating system's memory pool are re-enabled.

    This function can be used to impose a limit on the amount of system
    memory that is allocated by an application.  For example, if an
    application wishes to allocate no more than 200K bytes of memory, it
    could allocate 200K and immediately free it.  It can then call
    _heapenable to disable any further requests from the system memory pool.
     After this, the application can allocate memory from the 200K pool that
    it has already obtained.

Returns:
    The return value is the previous state of the system allocation flag.

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

    void main()
      {
        char *p;

        p = malloc( 200*1024 );
        if( p != NULL ) free( p );
        _heapenable( 0 );
        /*
          allocate memory from a pool that
          has been capped at 200K
        */
      }

Classification:
    WATCOM

Systems:
    All

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

See Also:

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