HANDLE LocalReAlloc(hMem,wBytes,wFlags)
This function changes the size of the local memory block specified by the hMem para-meter by increasing or decreasing its size to the number of bytes specified by the wBytes parameter, or changes the attributes of the specified memory block.
Parameter | Type/Description | |
hMem | HANDLE Identifies the local memory block to be reallocated. |
wBytes | WORD Specifies the new size of the memory block. | ||
wFlags | WORD Specifies how to reallocate the local memory block. It can be one or more of the following values: | ||
Value | Meaning | ||
LMEM_DISCARDABLE | Memory is discardable. This flag can only be used with LMEM_MODIFY. | ||
Parameter | Type/Description |
Value | Meaning | |
LMEM_MODIFY | Memory flags are modified. The wBytes parameter is ignored. This flag can only be used with LMEM_DISCARDABLE. | |
LMEM_MOVEABLE | Memory is moveable. If wBytes is zero, this flag causes a previously fixed block to be freed or a previously moveable object to be discarded (if the block's reference count is zero). If wBytes is nonzero and the block specified by hMem is fixed, this flag allows the reallocated block to be moved to a new fixed location. (Note that the handle returned by the LocalReAlloc function in this case may be different from the handle passed to the function.) This flag cannot be used with LMEM_MODIFY. | |
LMEM_NOCOMPACT | Memory will not be compacted or discarded to satisfy the allocation request. This flag cannot be used with LMEM_MODIFY. | |
LMEM_NODISCARD | Objects will not be discarded to satisfy the allocation request. This flag cannot be used with LMEM_MODIFY. | |
LMEM_ZEROINIT | If the block is growing, the additional memory contents are initialized to zero. This flag cannot be used with LMEM_MODIFY. |
The return value identifies the reallocated local memory if the function is successful. It is NULL if the local memory block cannot be reallocated.
The return value is always identical to the hMem parameter, unless the LMEM_MOVE-ABLE flag is used to allow movement of a fixed block of memory to a new fixed location.
If the data segment that contains the heap is moveable, calling this function will cause the data segment to move if Windows must increase the size of the heap and cannot increase the size of the heap in its current location. An application can prevent Windows from moving the data segment by calling the LockData function to lock the data segment.