_vheapinit

Description

Initializes the virtual memory manager.

#include <vmemory.h>

int __far _vheapinit( unsigned int dosmin, unsigned int dosmax,
unsigned int swaparea );

dosmin Minimum amount of DOS memory that must be available for the virtual memory manager to install itself, in paragraphs  
dosmax Maximum amount of DOS memory that the virtual memory manager can use, in paragraphs  
swaparea Type of auxiliary memory to use  

Remarks

The _vheapinit routine initializes the virtual memory manager in preparation for future allocations. It must be called before any virtual memory blocks are requested.

The _vheapinit function may round up the minimum value specified. After rounding, if the minimum amount of DOS memory is not available, _vheapinit does not initialize the virtual memory manager and returns 0. The virtual memory manager requires several kilobytes to function effectively.

If _VM_ALLDOS is specified for the dosmax argument, the virtual memory manager uses all available DOS memory.

The swaparea argument specifies which types of auxiliary memory the virtual memory manager can use to hold blocks of memory that are swapped out. The argument can be one or more of the following manifest constants, combined with the bitwise-OR operator (|):

Value Meaning

_VM_EMS Use expanded memory
_VM_XMS Use extended memory
_VM_DISK Use disk space
_VM_ALLSWAP ( _VM_EMS | _VM_XMS | _VM_DISK )

If not all of the specified forms of storage are available, the virtual memory manager uses what is available.

After the program is done using virtual memory, it must call _vheapterm to terminate the virtual memory manager. A program can contain multiple pairs of _vheapinit /_vheapterm calls.

Warning!:

If the program terminates without a call to _vheapterm, various system memory resources may not be available to subsequent programs.

To specify that no minimum amount of memory is required for installation of the virtual memory manager and to use all available DOS memory in the virtual heap and all auxiliary storage, use the following command:

if( _vheapinit( 0, _VM_ALLDOS, _VM_ALLSWAP) == 0 )

/* Error */

Return Value

The _vheapinit function returns a nonzero value if the virtual memory manager was successfully initialized. Otherwise, it returns 0.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_vheapterm

Example

See the example for _vmalloc.