LocalFree
The LocalFree
function frees the specified local memory object and invalidates its handle.
HLOCAL LocalFree(
|
HLOCAL hMem |
// handle of local
memory object |
|
); |
|
Parameters
hMem
Identifies
the local memory object. This handle is returned by either the LocalAlloc or LocalReAlloc function.
Return Values
If the
function succeeds, the return value is NULL.
If the
function fails, the return value is equal to the handle of the local memory
object. To get extended error information, call GetLastError.
Remarks
If the
process tries to examine or modify the memory after it has been freed, heap
corruption may occur or an access violation exception
(EXCEPTION_ACCESS_VIOLATION) may be generated.
If the hMem
parameter is NULL, LocalFree ignores the parameter and returns NULL.
LocalFree succeeds even if the memory object is locked by a
previous call to the LocalLock function. The LocalLock function
locks a local memory object and increments the lock count by one. The LocalUnlock
function unlocks it and decrements the lock count by one. To get the lock count
of a local memory object, use the LocalFlags function. LocalFree
will free a locked memory object. A locked memory object has a lock count
greater than zero.
Both GlobalFree and LocalFree will
free a locked memory object. However, if you run an application under a debug
version of Windows NT or Windows 95, both GlobalFree and LocalFree
will issue a message that tells you that this is happening. If you are
debugging the application, GlobalFree and LocalFree will enter a
hard-coded breakpoint just before freeing a locked object. This lets you
double-check the intended behavior.
See Also