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.
WinFreeMem (1.2)
◄Function Group► ◄Overview► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
#define INCL_WINHEAP
NPBYTE WinFreeMem(hHeap, npMem, cbMem)
HHEAP hHeap; /* handle of the heap */
NPBYTE npMem; /* address of memory block to free */
USHORT cbMem; /* size of the memory to free */
The WinFreeMem function frees memory allocated by the WinAllocMem function.
Parameter Description
────────────────────────────────────────────────────────────────────────────
hHeap Identifies the heap. This handle must have been created by a
previous call to the WinCreateHeap function.
npMem Points to the memory block to free. This parameter must have been
returned by a previous call to the WinAllocMem or WinReallocMem
function.
cbMem Specifies the size of the memory to free; it must match the
allocated size of the block.
Return Value
The return value is NULL if the function is successful. Otherwise, it
returns the npMem parameter. This method of returning failure allows for
updating the memory pointer and freeing the memory at the same time, which
can be accomplished with a call similar to the following:
npMem = WinFreeMem(hHeap, npMem, cbMem);
Comments
This function does not attempt to coalesce the block being freed with other
free blocks. Use the WinAvailMem function to coalesce free blocks.
If the heap was created with the HM_MOVEABLE option, the value of the cbMem
parameter is ignored and the value of the size word in the allocated memory
block is used instead.
If the heap was created with the HM_MOVEABLE and HM_VALIDSIZE options, the
value of the cbMem parameter is checked against the value of the size word
and an error is generated if the two values are not the same.
See Also
WinAllocMem, WinAvailMem, WinCreateHeap, WinReallocMem
♦