Differences
This shows you the differences between two versions of the page.
| en:docs:win16:api:kernel:localfree [2023/05/01 10:43] – created prokushev | en:docs:win16:api:kernel:localfree [2026/03/04 04:55] (current) – prokushev | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{page> | {{page> | ||
| - | ====== | + | ====== |
| ===== Brief ===== | ===== Brief ===== | ||
| + | Frees a local memory object and invalidates its handle. | ||
| ===== Syntax ===== | ===== Syntax ===== | ||
| + | <code c>HLOCAL WINAPI LocalFree( | ||
| + | HLOCAL hMem | ||
| + | );</ | ||
| ===== Parameters ===== | ===== Parameters ===== | ||
| - | ===== Return | + | hMem – Handle to the memory object to free. |
| + | |||
| + | ===== Return | ||
| + | |||
| + | Returns NULL if the function succeeds. | ||
| + | |||
| + | Returns the original handle if it fails. Call GetLastError for more information. | ||
| ===== Notes ===== | ===== Notes ===== | ||
| - | ===== Example Code ===== | + | After freeing, the handle is no longer valid. |
| - | ==== C Binding ==== | + | If hMem is NULL, the function does nothing and returns NULL. |
| + | It is safe to free a locked block, but doing so may cause memory corruption; always unlock before freeing. | ||
| + | |||
| + | In debug versions of Windows, freeing a locked block may generate a diagnostic message. | ||
| + | |||
| + | ===== Example Code ===== | ||
| + | ==== C Binding ==== | ||
| + | <code c>if (LocalFree(hMem) != NULL) { | ||
| + | // error handling | ||
| + | }</ | ||
| ==== MASM Binding ==== | ==== MASM Binding ==== | ||
| + | <code asm>push hMem | ||
| + | call LocalFree | ||
| + | cmp ax, 0 ; success if AX == 0</ | ||
| ===== See also ===== | ===== See also ===== | ||
| + | |||
| + | [[LocalAlloc]] | ||
| {{page> | {{page> | ||




