2.18 Virtual Memory Allocation

The virtual memory functions allow you to allocate, free, reallocate, lock, and unlock blocks of memory. The virtual memory functions are declared in the include file VMEMORY.H.

Routine Use

_vfree Frees an allocated block of virtual memory
_vheapinit Initializes the virtual memory manager
_vheapterm Terminates the virtual memory manager
_vload Loads an allocated block of virtual memory
_vlock Locks an allocated block of virtual memory
_vlockcnt Returns the number of locks held on a block of virtual memory
_vmalloc Allocates a block of virtual memory
_vmsize Returns the size of an allocated block of virtual memory
_vrealloc Reallocates a block of virtual memory to a new size
_vunlock Unlocks a locked block of virtual memory

The _vheapinit function specifies how much DOS memory the virtual memory manager can use and whether it should use expanded memory, extended memory, or disk storage. You must call this function before calling any of the other virtual memory functions.

The _vmalloc function returns a handle of type _vmhnd_t, which is used to refer to a block of virtual memory.

The _vfree, _vrealloc, _vload, _vlock, _vunlock, _vlockcnt, and _vmsize functions work on blocks of virtual memory specified by handles of type _vmdhnd_t.

The _vheapterm function frees all the resources used by the virtual memory manager. You must call this function after you have finished using virtual memory.