Jump to content

DosFreeMem: Difference between revisions

From EDM2
Created page with "=== Syntax === rc = DosFreeMem( ''pBaseAddress'' ); === Parameters === PVOID ''pBaseAddress'' (input) This variable should contain the base address of the private/shared..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
DosFreeMem will free the private or shared memory block from the process. The released page will automaticly get an access protection of 'no access'. If no other references to this memory block exists throughout the system, it will be discarded, and can later be reused.
=== Syntax ===
=== Syntax ===
 
DosFreeMem( ''pBaseAddress'' )
rc = DosFreeMem( ''pBaseAddress'' );
 


=== Parameters ===
=== Parameters ===
  PVOID ''pBaseAddress'' (input)
;PVOID ''pBaseAddress'' (input):This variable should contain the base address of the private/shared memory object, whose reference is to be freed.


This variable should contain the base address of the private/shared memory object,
whose reference is to be freed.
=== Returns ===
=== Returns ===
  APIRET rc
APIRET rc
 
The following values can be returned
The following values can be returned
   
{|class="wikitable"
{| border="1"
|0||NO_ERROR
|-
|-
|0
|5||ERROR_ACCESS_DENIED
|NO_ERROR
|-
|-
|5
|95||ERROR_INTERRUPT
|ERROR_ACCESS_DENIED
|-
|-
|95
|487||ERROR_INVALID_ADDRESS
|ERROR_INTERRUPT
|}
|-
 
|487
|ERROR_INVALID_ADDRESS
|}
=== Include Info ===
=== Include Info ===
  #define INCL_DOSMEMMGR
  #define INCL_DOSMEMMGR
  #include <os2.h>
  #include <os2.h>
 
 
=== Usage Explanation ===


DosFreeMem will free the private or shared memory block from the process. The released page
will automaticly get an access protection of 'no access'. If no other references to this
memory block exists throughout the system, it will be discarded, and can later be reused.
=== Relevant Structures ===
=== Gotchas ===
=== Sample Code ===
=== Sample Code ===
<pre>
<pre>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
#include  
#include <os2.h>


PVOID BaseAddress;  /* Pointer to the allocated memory block */
PVOID BaseAddress;  /* Pointer to the allocated memory block */
/* We allocate a memory block, and put the base address of it in BaseAddress */
/* We allocate a memory block, and put the base address of it in BaseAddress */
rc = DosFreeMem( BaseAddress);
rc = DosFreeMem( BaseAddress);
if (rc != 0)
if (rc != 0)
{
{
Line 64: Line 39:
   
   
=== See Also ===
=== See Also ===
[[OS2 API:CPI:DosAllocSharedMem|DosAllocSharedMem]], [[OS2 API:CPI:DosAllocMem|DosAllocMem]]  
*[[DosAllocSharedMem]]
 
*[[DosAllocMem]]  


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 14:58, 10 December 2022

DosFreeMem will free the private or shared memory block from the process. The released page will automaticly get an access protection of 'no access'. If no other references to this memory block exists throughout the system, it will be discarded, and can later be reused.

Syntax

DosFreeMem( pBaseAddress )

Parameters

PVOID pBaseAddress (input)
This variable should contain the base address of the private/shared memory object, whose reference is to be freed.

Returns

APIRET rc

The following values can be returned

0 NO_ERROR
5 ERROR_ACCESS_DENIED
95 ERROR_INTERRUPT
487 ERROR_INVALID_ADDRESS

Include Info

#define INCL_DOSMEMMGR
#include <os2.h>

Sample Code

#define INCL_DOSMEMMGR
#include <os2.h>

PVOID BaseAddress;  /* Pointer to the allocated memory block */
/* We allocate a memory block, and put the base address of it in BaseAddress */
	rc = DosFreeMem( BaseAddress);
	if (rc != 0)
	{
	  /* We got an error to take care of. */
	}

See Also