Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:docs:fapi:dosfreeseg [2021/08/20 03:44] – prokushev | en:docs:fapi:dosfreeseg [2021/12/05 09:56] (current) – prokushev | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| This call deallocates a memory segment. | This call deallocates a memory segment. | ||
| - | ==Syntax== | + | ===== Syntax  | 
| - |    | + | <code c> | 
| + | DosFreeSeg (Selector) | ||
| + | </ | ||
| - | ==Parameters== | + | ===== Parameters  | 
| * Selector ([[SEL]]) - input : Selector of the segment to be freed. | * Selector ([[SEL]]) - input : Selector of the segment to be freed. | ||
| - | ==Return Code== | + | ===== Return Code ===== | 
| - |    | + | rc ([[USHORT]]) - return | 
| Return code descriptions are: | Return code descriptions are: | ||
| Line 21: | Line 23: | ||
|   * 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  | + | DosFreeSeg frees selectors to segments returned  | 
| - | DosFreeSeg decrements the reference count for named shared segments allocated by DosAllocShrSeg. Access to the segment with [[DosGetShrSeg]] increments this count. When the count is 0, the memory is deallocated.  | + | 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 decrements the reference count for named shared segments allocated by [[DosAllocShrSeg]]. Access to the segment with [[DosGetShrSeg]] increments this count. When the count is 0, the memory is deallocated.  | ||
| + | |||
| + | ==== Family API Considerations ==== | ||
| - | ===Family API Considerations=== | ||
| 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: | 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: | ||
| Line 35: | Line 39: | ||
| If DosFreeSeg is issued on a CSAliased segment it deallocates the associated memory. This is inconsistent with the OS/2 mode, because DosFreeSeg must be performed on both the original and CSAliased selectors.  | If DosFreeSeg is issued on a CSAliased segment it deallocates the associated memory. This is inconsistent with the OS/2 mode, because DosFreeSeg must be performed on both the original and CSAliased selectors.  | ||
| - | ==Example Code== | + | ===== Example Code ===== | 
| - | ===C Binding=== | + | |
| + | ==== C Binding ==== | ||
| + | |||
| + | <code c> | ||
| #define INCL_DOSMEMMGR | #define INCL_DOSMEMMGR | ||
|    |    | ||
| Line 45: | Line 51: | ||
|    |    | ||
|   USHORT  |   USHORT  | ||
| + | </ | ||
| This example allocates a segment of 30,250 bytes and then discards the segment.  | This example allocates a segment of 30,250 bytes and then discards the segment.  | ||
| + | <code c> | ||
| #define INCL_DOSMEMMGR | #define INCL_DOSMEMMGR | ||
|    |    | ||
| Line 60: | Line 67: | ||
|                       |                       | ||
|    rc = DosFreeSeg(Selector);  |    rc = DosFreeSeg(Selector);  | ||
| + | </ | ||
| - | ===MASM Binding=== | + | ==== MASM Binding  | 
| + | <code asm> | ||
|   EXTRN  DosFreeSeg: |   EXTRN  DosFreeSeg: | ||
|   INCL_DOSMEMMGR  |   INCL_DOSMEMMGR  | ||
| Line 68: | Line 77: | ||
|   PUSH    |   PUSH    | ||
|   CALL    |   CALL    | ||
| + | </ | ||
| Returns WORD | Returns WORD | ||
| + | ===== Note ===== | ||
| - | |||
| - | ====== Note ====== | ||
| Text based on http:// | Text based on http:// | ||




