The LocalAlloc function allocates the specified number of bytes from the heap. In the linear Win32 API environment, there is no difference between the local heap and the global heap.
HLOCAL LocalAlloc(
UINT uFlags, |
// allocation attributes |
UINT uBytes |
// number of bytes to allocate |
); |
Flag |
Meaning |
LMEM_FIXED | |
Allocates fixed memory. This flag cannot be combined with the LMEM_MOVEABLE or LMEM_DISCARDABLE flag. The return value is a pointer to the memory block. To access the memory, the calling process simply casts the return value to a pointer. | |
LMEM_MOVEABLE | |
Allocates movable memory. This flag cannot be combined with the LMEM_FIXED flag. The return value is the handle of the memory object. The handle is a 32-bit quantity that is private to the calling process. To translate the handle into a pointer, use the LocalLock function. | |
LPTR | |
Combines the LMEM_FIXED and LMEM_ZEROINIT flags. | |
LHND | |
Combines the LMEM_MOVEABLE and LMEM_ZEROINIT flags. | |
NONZEROLHND | |
Same as the LMEM_MOVEABLE flag. | |
NONZEROLPTR | |
Same as the LMEM_FIXED flag. | |
LMEM_DISCARDABLE | |
Allocates discardable memory. This flag cannot be combined with the LMEM_FIXED flag. Some Win32-based applications may ignore this flag. | |
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. |
If the function succeeds, the return value is the handle of the newly allocated memory object.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
If the heap does not contain sufficient free space to satisfy the request, LocalAlloc returns NULL.
The GlobalAlloc and LocalAlloc functions are limited to a combined total of 65,536 handles for GMEM_MOVEABLE and LMEM_MOVEABLE memory per process. This limitation does not apply to GMEM_FIXED or LMEM_FIXED memory.
If this function succeeds, it allocates at least the amount requested. If the amount allocated is greater than the amount requested, the process can use the entire amount. To determine the actual number of bytes allocated, use the LocalSize function.
GlobalAlloc, LocalFree, LocalLock, LocalReAlloc, LocalSize
file: /Techref/os/win/api/win32/func/src/f54_3.htm, 7KB, , updated: 2000/4/7 11:19, local time: 2024/11/28 05:10,
3.149.239.79:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/TECHREF/os/win/api/win32/func/src/f54_3.htm"> LocalAlloc</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.