HLOCAL LocalReAlloc(hloc, cbNewSize, fuFlags) | |||||
HLOCAL hloc; | /* handle of local memory object | */ | |||
UINT cbNewSize; | /* new size of object | */ | |||
UINT fuFlags; | /* new allocation attributes | */ |
The LocalReAlloc function changes the size of the local memory block specified by the hloc parameter by increasing or decreasing its size to the number of bytes specified by the cbNewSize parameter, or changes the attributes of the specified memory block.
hloc
Identifies the local memory block to be reallocated.
cbNewSize
Specifies the new size of the memory block in bytes.
fuFlags
Specifies how to reallocate the local memory object. If this parameter includes the LMEM_MODIFY and LMEM_DISCARDABLE flags, LocalReAlloc ignores the fuNewSize parameter. The fuFlags parameter can be a combination of the following values:
Value | Meaning |
LMEM_DISCARDABLE | ||
Causes a previously movable object to become discardable. This flag can be used only with LMEM_MODIFY. | ||
LMEM_MODIFY | ||
Modifies the object's memory flags. This flag can be used only with LMEM_DISCARDABLE. | ||
LMEM_MOVEABLE | ||
If cbNewSize is zero, this flag causes a previously fixed object to be freed or a previously movable object to be discarded (if the object's lock count is zero). This flag cannot be used with LMEM_MODIFY. | ||
If cbNewSize is nonzero and the object identified by the hloc parameter is fixed, this flag allows the reallocated object to be moved to a new fixed location. | ||
LMEM_NOCOMPACT | ||
Prevents memory from being compacted or discarded to satisfy the allocation request. This flag cannot be used with LMEM_MODIFY. | ||
LMEM_ZEROINIT | ||
If the object is growing, this flag causes the additional memory contents to be initialized to zero. This flag cannot be used with LMEM_MODIFY. |
The return value is the handle of the reallocated local memory object, if the function is successful. Otherwise, it is NULL. Use the GetLastError function to obtain extended error information.
LocalAlloc