dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosReallocSeg (1.2)
Function Group  Overview  Changes               Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSMEMMGR
 
USHORT DosReallocSeg(usNewSize, sel)
USHORT usNewSize;    /* new segment size */
SEL sel;             /* segment selector */
 
The DosReallocSeg function reallocates a segment. The function changes the
size of the segment to the number of bytes specified by the usNewSize
parameter.
 
The DosReallocSeg function is a family API function.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
usNewSize  Specifies the new size (in bytes). The size can be any number
           from 0 through 65,535. If it is 0, the function allocates 65,536
           bytes.
 
sel        Specifies the selector of the segment to be reallocated. The
           selector must have been created previously by using DosAllocSeg
           or DosAllocShrSeg.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
 
     ERROR_ACCESS_DENIED
     ERROR_NOT_ENOUGH_MEMORY
 
Comments
 
The DosReallocSeg function does not change the shareable and discardable
attributes of the segment. If it was originally a shareable or discardable
segment, it remains a shareable or discardable segment. If DosReallocSeg
reallocates a discardable segment, however, it also locks the segment. You
must use the DosUnlockSeg function to unlock the segment and permit
discarding.
 
If the DosReallocSeg function is used to reallocate a shared segment to a
size smaller than its original size, the segment must have been created
using the DosAllocSeg function with the SEG_SIZEABLE attribute set. This
request can be issued from ring 2 or ring 3; the segment to be reallocated
can be a ring-2 or a ring-3 segment.
 
The DosReallocSeg function cannot be used to reallocate a segment created by
the DosCreateCSAlias function.
 
Restrictions
 
In real mode, the following restriction applies to the DosReallocSeg
function:
 
♦  The usNewSize parameter is rounded up to the next paragraph (16-byte)
   value.
 
Example
 
This example allocates a segment with 16,000 bytes, and then calls
DosReallocSeg to increase the size to 32,000 bytes:
 
SEL sel;
 
DosAllocSeg(16000, &sel, SEG_NONSHARED);   /* allocates memory   */
    .
    .
    .
DosReallocSeg(32000, sel);                 /* reallocates memory */
 
See Also
 
DosAllocSeg, DosFreeSeg, DosLockSeg, DosReallocHuge, DosUnlockSeg