Jump to content

DosSubFreeMem: Difference between revisions

From EDM2
Created page with "=== Syntax === rc = DosSubFreeMem( ''pOffset'', ''pBlockOffset'', ''ulSize'' ); === Parameters === PVOID ''pOffset'' (input) T..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Syntax ===
=== Syntax ===
 
  DosSubFreeMem( ''pOffset'', ''pBlockOffset'', ''ulSize'' )
  rc = DosSubFreeMem( ''pOffset'',  
                    ''pBlockOffset'',  
                    ''ulSize'' );
 


=== Parameters ===
=== Parameters ===
PVOID ''pOffset'' (input)
;PVOID ''pOffset'' (input):The Offset of the memory pool that contains the block that should be freed.
 
;PVOID ''pBlockOffset'' (input):The offset of the memory block to be freed. It's important that this is equal to an offset returned by a previous allocation using [[DosSubAllocMem]].
The Offset of the memory pool that contains the block that should be freed.
;ULONG ''ulSize'' (input):The size in bytes of the memory block that is to be freed.
 
 
PVOID ''pBlockOffset'' (input)
 
The offset of the memory block to be freed. It's important that this
is equal to an offset returned by a previous allocation using [[DosSubAllocMem]].
 
 
ULONG ''ulSize'' (input)
 
The size in bytes of the memory block that is to be freed.
 
   
   
=== Returns ===
=== Returns ===
  APIRET rc
APIRET rc
The following values can be returned
The following values can be returned    
     
{{RetVal
{| border="1"
|v1=87
|-
|w1=ERROR_INVALID_PARAMETER
|0
|v2=312
|NO_ERROR
|w2=ERROR_DOSSUB_OVERLAP
|-
|v3=532
|87
|w3=ERROR_DOSSUB_CORRUPTED
|ERROR_INVALID_PARAMETER
}}
|-
|312
|ERROR_DOSSUB_OVERLAP
|-
|532
|ERROR_DOSSUB_CORRUPTED
|}
=== Include Info ===
 
#define INCL_DOSMEMMGR
#include <bsememf.h>
#include <os2.h>
 


=== Usage Explanation ===
=== Usage Explanation ===
DosSubFreeMem is used to free a memory block that was allocated with [[DosSubAllocMem]]. Size is the size in bytes of the memory block to be freed. It is supposed to be a multiple of 8
bytes, and if not it is rounded up. The maximum value for Size is the size of the memory pool, allocated with [[DosSubSetMem]], minus 64 bytes.


DosSubFreeMem is used to free a memory block that was allocated with [[DosSubAllocMem]].  Size is the size in bytes
of the memory block to be freed.  It is supposed to be a multiple of 8
bytes, and if not it is rounded up.  The maximum value for Size is the size
of the memory pool, allocated with [[DosSubSetMem]], minus 64 bytes. 
=== Relevant Structures ===
=== Gotchas ===
=== Gotchas ===
The maximum value for Size is the size of the memory pool, allocated with
The maximum value for Size is the size of the memory pool, allocated with
[[DosSubSetMem]], minus 64 bytes.
[[DosSubSetMem]], minus 64 bytes.


=== Sample Code ===
=== Sample Code ===
<pre>
<pre>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
#include  
#include <bsememf.h>
#include  
#include <os2.h>


PVOID Offset;
PVOID Offset;
Line 85: Line 48:
</pre>  
</pre>  
=== See Also ===
=== See Also ===
[[OS2 API:CPI:DosSubAllocMem|CPI:DosSubAllocMem]], [[OS2 API:CPI:DosSubSetMem|CPI:DosSubSetMem]], [[OS2 API:CPI:DosSubUnsetMem|CPI:DosSubUnsetMem]]
*[[DosSubAllocMem]]
*[[DosSubSetMem]]
*[[DosSubUnsetMem]]


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

Latest revision as of 20:51, 30 October 2017

Syntax

DosSubFreeMem( pOffset, pBlockOffset, ulSize )

Parameters

PVOID pOffset (input)
The Offset of the memory pool that contains the block that should be freed.
PVOID pBlockOffset (input)
The offset of the memory block to be freed. It's important that this is equal to an offset returned by a previous allocation using DosSubAllocMem.
ULONG ulSize (input)
The size in bytes of the memory block that is to be freed.

Returns

APIRET rc

The following values can be returned

0 NO_ERROR
87 ERROR_INVALID_PARAMETER
312 ERROR_DOSSUB_OVERLAP
532 ERROR_DOSSUB_CORRUPTED


Usage Explanation

DosSubFreeMem is used to free a memory block that was allocated with DosSubAllocMem. Size is the size in bytes of the memory block to be freed. It is supposed to be a multiple of 8 bytes, and if not it is rounded up. The maximum value for Size is the size of the memory pool, allocated with DosSubSetMem, minus 64 bytes.

Gotchas

The maximum value for Size is the size of the memory pool, allocated with DosSubSetMem, minus 64 bytes.

Sample Code

#define INCL_DOSMEMMGR
#include <bsememf.h>
#include <os2.h>

PVOID Offset;
PVOID BlockOffset;
ULONG Size;
APIRET rc;

size = 128;

rc = DosSubFreeMem( Offset, BlockOffset, Size);

if (rc != 0)
{
   /* We have an error we must take care of. */
}

See Also