Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:docs:fapi:dosfreeseg [2018/08/30 16:27] – created prokushev | en:docs:fapi:dosfreeseg [2021/12/05 09:56] (current) – prokushev | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{page> | ||
+ | ====== DosFreeSeg ====== | ||
This call deallocates a memory segment. | This call deallocates a memory segment. | ||
- | ==Syntax== | + | ===== Syntax ===== |
- | | + | |
- | ==Parameters== | + | <code c> |
- | ;Selector ([[SEL]]) - input : Selector of the segment to be freed. | + | DosFreeSeg (Selector) |
+ | </ | ||
+ | |||
+ | ===== Parameters ===== | ||
+ | |||
+ | | ||
+ | |||
+ | ===== Return Code ===== | ||
+ | |||
+ | rc ([[USHORT]]) - return | ||
- | ==Return Code== | ||
- | rc (USHORT) - return | ||
Return code descriptions are: | Return code descriptions are: | ||
- | * 0 | + | |
- | * 5 | + | * 5 |
- | * 212 | + | * 212 |
- | ==Remarks== | + | ===== Remarks ===== |
- | DosFreeSeg frees selectors to segments returned by allocation calls to [[DosAllocSeg]], | + | |
- | When allocated memory is shared, all selectors to the shared memory must be freed before the memory is deallocated. For example, if memory allocated by DosAllocSeg or DosAllocHuge has been given to another process with [[DosGiveSeg]], | ||
- | DosFreeSeg | + | DosFreeSeg |
- | ===Family API Considerations=== | + | When allocated memory is shared, all selectors to the shared memory must be freed before the memory is deallocated. For example, if memory allocated by [[DosAllocSeg]] or [[DosAllocHuge]] has been given to another process with [[DosGiveSeg]], the giver usually frees its selector by a call to DosFreeSeg. The recipient, in turn, frees the selector passed to it, after it has accessed the shared memory with [[DosGetSeg]]. |
- | Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restriction applies | + | |
- | If DosFreeSeg | + | DosFreeSeg |
- | ==Example Code== | + | ==== Family API Considerations |
- | ===C Binding=== | + | |
- | < | + | |
- | #define INCL_DOSMEMMGR | + | |
- | USHORT | ||
- | SEL Selector; | + | Some options operate differently in the DOS mode than in OS/2 mode. Therefore, the following restriction applies to DosFreeSeg when coding for the DOS mode: |
- | USHORT | + | If DosFreeSeg is issued on a CSAliased |
- | </ | + | |
- | This example allocates | + | |
- | < | + | |
- | #define INCL_DOSMEMMGR | + | |
- | #define NUMBER_OF_BYTES 30250 | + | ===== Example Code ===== |
- | #define ALLOC_FLAG SEG_GETTABLE | + | |
- | SEL Selector; | + | ==== C Binding ==== |
- | USHORT rc; | + | |
+ | <code c> | ||
+ | #define INCL_DOSMEMMGR | ||
+ | |||
+ | USHORT | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | </ | ||
+ | This example allocates a segment of 30,250 bytes and then discards the segment. | ||
- | rc = DosAllocSeg(NUMBER_OF_BYTES, | + | <code c> |
- | & | + | #define INCL_DOSMEMMGR |
- | ALLOC_FLAG); | + | |
+ | #define NUMBER_OF_BYTES 30250 | ||
+ | #define ALLOC_FLAG SEG_GETTABLE | ||
+ | |||
+ | SEL Selector; | ||
+ | USHORT rc; | ||
+ | |||
+ | rc = DosAllocSeg(NUMBER_OF_BYTES, | ||
+ | & | ||
+ | | ||
rc = DosFreeSeg(Selector); | rc = DosFreeSeg(Selector); | ||
- | </PRE> | + | </code> |
- | ===MASM Binding=== | + | |
- | < | + | |
- | EXTRN DosFreeSeg: | + | |
- | INCL_DOSMEMMGR | + | |
- | PUSH | + | ==== MASM Binding ==== |
- | CALL | + | |
+ | <code asm> | ||
+ | EXTRN DosFreeSeg: | ||
+ | INCL_DOSMEMMGR | ||
+ | | ||
+ | PUSH | ||
+ | CALL | ||
+ | </ | ||
Returns WORD | Returns WORD | ||
- | </ | ||
+ | ===== Note ===== | ||
- | ====== Note ====== | ||
Text based on http:// | Text based on http:// |