home *** CD-ROM | disk | FTP | other *** search
- /***
- *vheap.c - Virtual Heap
- *
- * Copyright (c) 1990-1992, Microsoft Corporation. All rights reserved.
- *
- *Purpose:
- * Contains C wrappers for certain VM routines.
- *
- *******************************************************************************/
-
- #include <vmemory.h>
- #include <system.h>
- #include <vmm.h>
- #include <vmbm.h>
- #include <vmp.h>
-
- /*
- * set max allocation size such that rounded up
- * it will be less than 64K.
- */
-
- #define _VM_MAXALLOC 65530
-
-
- /***
- * _vmalloc - Allocate a VM block
- *
- *Purpose:
- * Allocate a VM block.
- *
- * Make sure the block is smaller than the size of the DOS swap
- * area (i.e., make sure any block that is allocated can be later
- * loaded).
- *
- * Then call VMBM to do all the work.
- *
- *Entry:
- * size = size of block to allocate (in bytes)
- *
- *Exit:
- * success: handle of block
- * failure: _VM_NULL
- *
- *Exceptions:
- *
- *******************************************************************************/
-
- _vmhnd_t _far _pascal __vmalloc(unsigned long size)
- {
-
- if ( (size > _VM_MAXALLOC) ||
- (size > ((unsigned long)(((unsigned long)_cPageDos-1) * cbVmPage)))
- )
- return(_VM_NULL);
-
- return((_vmhnd_t)__HbkVmAllocate(size));
-
- }
-
-
- /***
- * _vrealloc - Reallocate a VM block
- *
- *Purpose:
- * Reallocate a VM block.
- *
- * (1) Make sure the block is smaller than the size of the DOS swap
- * area (i.e., make sure any block that is allocated can be later
- * loaded).
- *
- * (2) If supplied handle is not NULL, make sure block is not locked.
- *
- * Then call VMBM to do all the work.
- *
- *Entry:
- * size = size of block to allocate (in bytes)
- *
- *Exit:
- * success: handle of block
- * failure: _VM_NULL
- *
- *Exceptions:
- *
- *******************************************************************************/
-
- _vmhnd_t _far _pascal __vrealloc(_vmhnd_t vhnd, unsigned long size)
- {
-
- if ( ((vhnd != _VM_NULL) && (_vlockcnt(vhnd) != 0)) ||
- (size > _VM_MAXALLOC) ||
- (size > ((unsigned long)(((unsigned long)_cPageDos-1) * cbVmPage)))
- )
- return(_VM_NULL);
-
- return((_vmhnd_t)__HbkVmReallocate((HBK)vhnd, size));
-
- }
-