Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
WinReallocMem (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_WINHEAP
NPBYTE WinReallocMem(hHeap, npMem, cbOld, cbNew)
HHEAP hHeap; /* handle of the heap */
NPBYTE npMem; /* address of memory block to reallocate */
USHORT cbOld; /* old memory block length */
USHORT cbNew; /* new memory block length */
The WinReallocMem function reallocates the size of a memory block on the
heap.
The calling routine must specify both the old size of the memory object and
the new size. If the new size is larger than the old size, then this
function calls the WinAllocMem function to allocate the new, larger object,
copies the number of bytes specified by the cbOld parameter from the old
object to the new, frees the old object, and returns a pointer to the new
object. (It never causes an object to grow in place.)
If the passed heap is created with the HM_MOVEABLE option, then the value of
the cbOld parameter is ignored and the value in the size word of the
allocated object is used. On completion, the size word contains the value of
the cbNew parameter. If this function has to move the object in order to
satisfy the request, then the handle value word is updated by adding to it
the distance of the move, in bytes. The returned address is then the address
of the first reserved word.
Parameter Description
────────────────────────────────────────────────────────────────────────────
hHeap Identifies the heap. This parameter must have been returned from
a previous call to the WinCreateHeap function.
npMem Points to the memory block to be reallocated. The low two bits of
npMem are ignored, although they are preserved in the return
value of this function, even if the memory object is moved as a
result of growing. Except for the two low bits, the value of the
npMem parameter must have been returned by either the
WinAllocMem function or a previous call to WinReallocMem.
cbOld Specifies the old size of the memory block, in bytes.
cbNew Specifies the new size of the memory block, in bytes.
Return Value
The return value is a pointer to the reallocated memory block if the
function was successful. Otherwise, it is NULL, indicating that the memory
could not be reallocated to the requested size.
The return pointer is a 16-bit offset from the start of the segment
containing the heap of the reallocated memory object. The function returns
NULL when the memory object cannot be reallocated because an invalid heap
handle is specified, there is not enough room in the heap to increase the
object to the specified size, or the npMem parameter points to memory
outside the bounds of the passed heap.
See Also
WinAllocMem, WinCreateHeap, WinFreeMem
♦