|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| Yes
| Win32s
| Yes
| Import Library
| kernel32.lib
| Header File
| winbase.h
| Unicode
| No
| Platform Notes
| None
|
|
|
LocalAlloc
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
|
);
|
|
Parameters
uFlags
Specifies how to allocate memory. If zero is specified, the default is the
LMEM_FIXED flag. Except for the incompatible combinations that are specifically
noted, any combination of the following flags can be specified. To indicate
whether the function allocates fixed or movable memory, specify one of the first six
flags:
| 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.
|
| 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.
|
| Combines the LMEM_FIXED and LMEM_ZEROINIT flags.
|
| Combines the LMEM_MOVEABLE and LMEM_ZEROINIT flags.
|
| Same as the LMEM_MOVEABLE flag.
|
| Same as the LMEM_FIXED flag.
|
| Allocates discardable memory. This flag cannot be combined with the LMEM_FIXED
flag. Some Win32-based applications may ignore this flag.
|
| Does not compact or discard memory to satisfy the allocation request.
|
| Does not discard memory to satisfy the allocation request.
|
| Initializes memory contents to zero.
|
uBytes
Specifies the number of bytes to allocate. If this parameter is zero and the
uFlags parameter specifies the LMEM_MOVEABLE flag, the function returns a handle to
a memory object that is marked as discarded.
Return Values
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.
Remarks
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.
See Also
GlobalAlloc,
LocalFree,
LocalLock,
LocalReAlloc,
LocalSize
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database