en:docs:fapi:dosfreeseg

Differences

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

Link to this comparison view

en:docs:fapi:dosfreeseg [2018/08/30 18:27]
prokushev created
en:docs:fapi:dosfreeseg [2018/09/02 18:35] (current)
prokushev
Line 1: Line 1:
 +{{logos:​os2.gif?​35x35}} {{logos:​dos.gif?​35x35}}
 +====== DosFreeSeg ======
  
 This call deallocates a memory segment. This call deallocates a memory segment.
  
 ==Syntax== ==Syntax==
- ​DosFreeSeg (Selector)+ 
 +  ​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+ 
 +  rc (USHORT) - return 
 Return code descriptions are: Return code descriptions are:
-* 0         ​NO_ERROR +  ​* 0         ​NO_ERROR 
-* 5         ​ERROR_ACCESS_DENIED  +  * 5         ​ERROR_ACCESS_DENIED  
-* 212       ​ERROR_LOCKED+  * 212       ​ERROR_LOCKED
  
 ==Remarks== ==Remarks==
 +
 DosFreeSeg frees selectors to segments returned by allocation calls to [[DosAllocSeg]],​ [[DosAllocShrSeg]],​ and [[DosAllocHuge]]. In addition, DosFreeSeg frees a selector returned by a call to [[DosCreateCSAlias]]. If a CS alias selector has been created for a data segment by a call to DosCreateCSAlias,​ the CS alias selector is still valid after the segment'​s data selector has been freed. DosFreeSeg frees selectors to segments returned by allocation calls to [[DosAllocSeg]],​ [[DosAllocShrSeg]],​ and [[DosAllocHuge]]. In addition, DosFreeSeg frees a selector returned by a call to [[DosCreateCSAlias]]. If a CS alias selector has been created for a data segment by a call to DosCreateCSAlias,​ the CS alias selector is still valid after the segment'​s data selector has been freed.
  
Line 23: Line 30:
  
 ===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 29: Line 37:
 ==Example Code== ==Example Code==
 ===C Binding=== ===C Binding===
-<PRE> 
-#define INCL_DOSMEMMGR 
  
-USHORT ​ rc = DosFreeSeg(Selector);​+  #define INCL_DOSMEMMGR 
 +   
 +  ​USHORT ​ rc = DosFreeSeg(Selector);​ 
 +   
 +  SEL              Selector; ​     /* Selector */ 
 +   
 +  USHORT ​          ​rc; ​           /* return code */
  
-SEL              Selector; ​     /* Selector */ 
- 
-USHORT ​          ​rc; ​           /* return code */ 
-</​PRE>​ 
 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. ​
-<PRE> 
-#define INCL_DOSMEMMGR 
  
-#define NUMBER_OF_BYTES 30250 +  #define INCL_DOSMEMMGR 
-#define ALLOC_FLAG SEG_GETTABLE+   
 +  ​#define NUMBER_OF_BYTES 30250 
 +  #define ALLOC_FLAG SEG_GETTABLE 
 +   
 +  SEL    Selector; 
 +  USHORT rc; 
 +   
 +     rc = DosAllocSeg(NUMBER_OF_BYTES, ​    /* # of bytes requested */ 
 +                      &​Selector, ​          /* Selector allocated */ 
 +                     ​ALLOC_FLAG); ​        /* Allocation flags */ 
 +   rc = DosFreeSeg(Selector); ​           /* Segment selector */
  
-SEL    Selector; 
-USHORT rc; 
- 
-   rc = DosAllocSeg(NUMBER_OF_BYTES, ​    /* # of bytes requested */ 
-                    &​Selector, ​          /* Selector allocated */ 
-                    ALLOC_FLAG); ​        /* Allocation flags */ 
-   rc = DosFreeSeg(Selector); ​           /* Segment selector */ 
-</​PRE>​ 
 ===MASM Binding=== ===MASM Binding===
-<PRE> 
-EXTRN  DosFreeSeg:​FAR 
-INCL_DOSMEMMGR ​     EQU 1 
  
-PUSH   ​WORD ​   Selector ​     ;Selector +  EXTRN  DosFreeSeg:​FAR 
-CALL   ​DosFreeSeg+  INCL_DOSMEMMGR ​     EQU 1 
 +   
 +  ​PUSH   ​WORD ​   Selector ​     ;Selector 
 +  CALL   ​DosFreeSeg
  
 Returns WORD Returns WORD
-</​PRE>​+
  
  

en/docs/fapi/dosfreeseg.txt · Last modified: 2018/09/02 18:35 by prokushev