Compartilhar via


LocalFree

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function frees the specified local memory object and invalidates its handle.

Syntax

HLOCAL LocalFree(
  HLOCAL hMem
);

Parameters

  • hMem
    Handle to the local memory object.

    This handle is returned by either the LocalAlloc or LocalReAlloc function.

Return Value

NULL indicates success. A handle to the local memory object indicates failure. To get extended error information, call GetLastError.

Remarks

If the process tries to examine or modify the memory after it is freed, heap corruption can occur or an access violation exception (EXCEPTION_ACCESS_VIOLATION) can be generated.

If the hMem parameter is NULL, LocalFree ignores the parameter and returns NULL.

The LocalFree function will free a locked memory object. A locked memory object has a lock count greater than zero.

If an application is running under a debug version of the system, LocalFree issues a message that tells you that a locked object is being freed. If you are debugging the application, LocalFree enters a breakpoint just before freeing a locked object. This allows you to verify the intended behavior and then continue execution.

For Windows CE 1.0 through Windows CE 2.12, allocating memory approximately 0 to 7 bytes under 192K in size causes the corresponding call to LocalFree to fail for certain memory blocks in this size range. The return code is ERROR_INVALID_PARAMETER.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Memory Management Functions
LocalAlloc
LocalReAlloc