[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _xvrealloc()
 Change the size of a VM segment
------------------------------------------------------------------------------
 C Prototype

     #include "vm.api"
     HANDLE _xvrealloc(
                        HANDLE hSegment,
                        USHORT uiSize,
                        USHORT uiFlags
                      )

 Arguments

     hSegment is the VM segment handle returned by _xvalloc().

     uiSize is the new VM segment size in bytes.

     uiFlags is currently unused and must be set to zero.

 Returns

     If successful, _xvrealloc() returns the original VM segment handle;
     otherwise, it returns zero.

 Description

     _xvrealloc() resizes a previously allocated VM segment, shortening or
     lengthening the VM segment to match the specified size.  If you shorten
     the VM segment, bytes at the end of the segment are lost.

     If the resizing is unsuccessful (indicated by a return value of zero),
     the segment retains its original size.

     Note:  _xvrealloc() can resize locked segments, but the chance of
     success is lower because the function will be constrained by other
     locked segments that are currently in memory.

     Warning!  Use _xvheapresize(), not _xvrealloc(), to resize a segment
     heap.

 Examples

     .  This example resizes a previously allocated segment:

        // CA-Clipper include files
        #include "vm.api"

        #define VR_SHRANK     1
        #define VR_GREW       2
        #define VR_NOCHANGE   3
        #define VR_ERROR      0

        // Prototype
        int VMResizeExample(HANDLE hSegment, unsigned uiNewSize);


        int VMResizeExample(HANDLE hSegment, unsigned uiNewSize)
        {
           int iResult = VR_ERROR;
           unsigned int uiOldSize;
           long lChange;

           uiOldSize = _xvsize(hSegment);


           // Attempt to resize and assign result
           //
           if (_xvrealloc(hSegment, uiNewSize, 0))
              {
              lChange = (_xvsize(hSegment) - uiOldSize);

              if (lChange > 0)
                 iResult = VR_GREW;

              if (lChange == 0)
                 iResult = VR_NOCHANGE;

              if (lChange < 0)
                 iResult = VR_SHRANK;
              }

           return (iResult);
        }

 Files  Library is CLIPPER.LIB, header file is Vm.api.


See Also: _xvalloc() _xvheapresize() _xvsize()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson