(file) Return to String.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/String.cpp between version 1.140 and 1.141

version 1.140, 2014/06/14 16:14:04 version 1.141, 2014/07/17 19:55:40
Line 382 
Line 382 
     return p - (Uint8*)dest;     return p - (Uint8*)dest;
 } }
  
 //  Function to return a formatted char*  from a va_list.  
 //  Allocates space for the returned char* and repeats the  
 //  build process until the allocated space is large enough  
 //  to hold the result.  This is internal only and the core function  
 //  used by stringPrintf and stringVPrintf  
   
 static char* _charVPrintf(const char* format, va_list ap)  
 {  
     // Iniitial allocation size.  This is a guess assuming that  
     // most printfs are one or two lines long  
     int allocSize = 256;  
   
     int rtnSize;  
     char *p;  
   
     // initial allocate for output  
     if ((p = (char*)malloc(allocSize)) == NULL)  
     {  
         return 0;  
     }  
   
     // repeat formatting  with increased realloc until it works.  
     do  
     {  
         rtnSize = vsnprintf(p, allocSize, format, ap);  
   
         // return if successful if not negative and  
         // returns less than allocated size.  
         if (rtnSize > -1 && rtnSize < allocSize)  
         {  
             return p;  
         }  
   
         // increment alloc size. Assumes that positive return is  
         // expected size and negative is error.  
         allocSize = (rtnSize > -1)? (rtnSize + 1) : allocSize * 2;  
   
     } while((p = (char*)peg_inln_realloc(p, allocSize)) != NULL);  
   
     // return error code if realloc failed  
     return 0;  
 }  
   
 //============================================================================== //==============================================================================
 // //
 // class CString // class CString


Legend:
Removed from v.1.140  
changed lines
  Added in v.1.141

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2