LocalReAlloc

2.x

  HLOCAL LocalReAlloc(hloc, fuNewSize, fuFlags)    
  HLOCAL hloc; /* handle of local memory object */
  UINT fuNewSize; /* new size of object */
  UINT fuFlags; /* new allocation attributes */

The LocalReAlloc function changes the size or attributes of the given local memory object.

Parameters

hloc

Identifies the local memory object to be reallocated.

fuNewSize

Specifies the new size of the local memory object.

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 fuNewSize 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 fuNewSize 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.

Return Value

The return value is the handle of the reallocated local memory object, if the function is successful. Otherwise, it is NULL.

Comments

If LocalReAlloc reallocates a movable object, the return value is a local handle of the memory. To access the memory, an application must use the LocalLock function to convert the handle to a pointer.

If LocalReAlloc reallocates a fixed object, the return value is a pointer to the memory. To access the memory, an application can simply cast the return value to a pointer.

To free a local memory object, an application should use the LocalFree function.

See Also

LocalAlloc, LocalDiscard, LocalFree, LocalLock