[Previous]
[Contents]
[Next]

_heapenable()

enable or disable requests to expand a heap

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:

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 previous state of the system allocation flag.

Examples:

#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

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

_heapchk(), _heapgrow(), _heapmin(), _heapset(), _heapshrink(), _heapwalk()


[Previous]
[Contents]
[Next]