home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 8.ddi / IOSTRSR1.ZIP / STUSIZE.CPP < prev   
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.3 KB  |  44 lines

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     stusize.cpp                                              |*/
  4. /*|                                                              |*/
  5. /*|     Class ios                                                |*/
  6. /*|          void ios::usersize( int )                           |*/
  7. /*|                                                              |*/
  8. /*[]------------------------------------------------------------[]*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1990, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18. #include <ioconfig.h>
  19. #include <iostream.h>
  20. #include "user.h"
  21.  
  22. // allocate or resize user array -- we assume i > nwords
  23.  
  24. void ios::usersize(int i)
  25. {
  26.     // allocate space for new array
  27.     ios_user_union *p = new ios_user_union[i];
  28.  
  29.     if( ! p )
  30.         return;     // cannot enlarge array
  31.  
  32.     if( nwords )
  33.         {  // copy old array to new one
  34.         memcpy(p, userwords, nwords * sizeof(ios_user_union));
  35.         delete userwords;
  36.         }
  37.     userwords = p;
  38.     do  {        // set new words to zero
  39.         p[nwords].lword = 0;
  40.         } while( ++nwords < i );
  41. }
  42.  
  43.  
  44.