Logo Search packages:      
Sourcecode: condor version File versions  Download package

bool MyString::vsprintf_cat ( const char *  format,
va_list  args 
)

Like vsprintf, but this appends to existing data.

Definition at line 482 of file MyString.cpp.

References reserve_at_least(), and vsprintf().

Referenced by sprintf_cat(), and vsprintf().

{
      char *buffer = NULL;
      int s_len;

    if( !format || *format == '\0' ) {
            return true;
      }
#if HAVE_VASPRINTF
      s_len = vasprintf(&buffer, format, args);
      if (-1 == s_len) { // if alloc not possible or other error
            return false;
      }
#else
    s_len = vprintf_length(format,args);
#endif
    if( Len + s_len > capacity || !Data ) {
            if(!reserve_at_least( Len + s_len )) {
                  free(buffer);
                  return false;
            }
    }
#if HAVE_VASPRINTF
            // Ideally this would not be necessary, instead we'd just
            // asprintf into Data. However, we manage Data with
            // new/delete.
      memcpy(Data + Len, buffer, s_len + 1);
      free(buffer);
#else
	::vsprintf(Data + Len, format, args);
#endif
      Len += s_len;
    return true;
}


Generated by  Doxygen 1.6.0   Back to index