HANDLE LocalAlloc(wFlags,wBytes)
This function allocates the number of bytes of memory specified by the wBytes parameter from the local heap. The memory block can be either fixed or moveable, as specified by the wFlags parameter.
Parameter | Type/Description |
wFlags | WORD Specifies how to allocate memory. It can be one or more of the following values: | ||
Value | Meaning | ||
LMEM_DISCARDABLE | Allocates discardable memory. Can only be used with LMEM_MOVEABLE. | ||
LMEM_FIXED | Allocates fixed memory. | ||
LMEM_MODIFY | Modifies the LMEM_DISCARDABLE flag. Can only be used with LMEM_DISCARDABLE. | ||
LMEM_MOVEABLE | Allocates moveable memory. Cannot be used with LMEM_FIXED. | ||
LMEM_NOCOMPACT | Does not compact or discard memory to satisfy the allocation request. | ||
LMEM_NODISCARD | Does not discard memory to satisfy the allocation request. | ||
LMEM_ZEROINIT | Initializes memory contents to zero. | ||
Choose LMEM_FIXED or LMEM_MOVEABLE, and then combine others as needed by using the bitwise OR operator. | |||
wBytes | WORD Specifies the total number of bytes to be allocated. |
The return value identifies the newly allocated local memory block if the function is successful. Otherwise, it is NULL.
If the data segment that contains the heap is moveable, calling this function will cause the data segment to move if Windows needs to 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.
If this function is successful, it allocates at least the amount requested. The actual amount allocated may be greater. To determine the actual amount allocated, call the LocalSize function.