en:docs:win16:api:kernel:localfree

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:docs:win16:api:kernel:localfree [2023/05/01 10:43] – created prokusheven:docs:win16:api:kernel:localfree [2026/03/04 04:55] (current) prokushev
Line 1: Line 1:
 {{page>en:templates:win16api}} {{page>en:templates:win16api}}
  
-======  ======+====== LocalFree ======
  
 ===== Brief ===== ===== Brief =====
 +Frees a local memory object and invalidates its handle.
  
 ===== Syntax ===== ===== Syntax =====
 +<code c>HLOCAL WINAPI LocalFree(
 +HLOCAL hMem
 +);</code>
  
 ===== Parameters ===== ===== Parameters =====
  
-===== Return Code =====+hMem – Handle to the memory object to free. 
 + 
 +===== Return Value ===== 
 + 
 +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
 +}</code>
 ==== MASM Binding ==== ==== MASM Binding ====
 +<code asm>push hMem
 +call LocalFree
 +cmp ax, 0 ; success if AX == 0</code>
  
 ===== See also ===== ===== See also =====
 +
 +[[LocalAlloc]]
  
 {{page>en:templates:win16}} {{page>en:templates:win16}}