third_party/tinyxml/tinystr.cpp
void TiXmlString::append( const char * suffix )
{
    char * new_string;
    size_t new_alloc, new_size;

    new_size = length () + strlen (suffix) + 1;
    // check if we need to expand
    if (new_size > allocated)
    {
        // compute new size
        new_alloc = assign_new_size (new_size);

        // allocate new buffer
        new_string = new char [new_alloc];        
        new_string [0] = 0;

        // copy the previous allocated buffer into this one
        if (allocated && cstring)
            memcpy (new_string, cstring, 1 + length ());
            // strcpy (new_string, cstring);

        // append the suffix. It does exist, otherwize we wouldn't be expanding 
        // strcat (new_string, suffix);
        memcpy (new_string + length (), 
                suffix,
                strlen (suffix) + 1);

        // return previsously allocated buffer if any
        if (allocated && cstring)
            delete [] cstring;

        // update member variables
        cstring = new_string;
        allocated = new_alloc;
    }
    else
    {
        // we know we can safely append the new string
        // strcat (cstring, suffix);
        memcpy (cstring + length (), 
                suffix, 
                strlen (suffix) + 1);
    }
    current_length = new_size - 1;
}
// append a const char * to an existing TiXmlString
append a const char * to an existing TiXmlString
append a const char * to an existing TiXmlString
void TiXmlString::append( const char * suffix )
{
    char * new_string;
    size_t new_alloc, new_size;
    new_size = length () + strlen (suffix) + 1;
    if (new_size > allocated)
    {
        new_alloc = assign_new_size (new_size);
        new_string = new char [new_alloc];        
        new_string [0] = 0;
        if (allocated && cstring)
            memcpy (new_string, cstring, 1 + length ());
        memcpy (new_string + length (), 
                suffix,
                strlen (suffix) + 1);
        if (allocated && cstring)
            delete [] cstring;
        cstring = new_string;
        allocated = new_alloc;
    }
    else
    {
        memcpy (cstring + length (), 
                suffix, 
                strlen (suffix) + 1);
    }
    current_length = new_size - 1;
}
void TiXmlString :: append ( const char * suffix ) { char * new_string ; size_t new_alloc , new_size ; new_size = length ( ) + strlen ( suffix ) + 1 ; if ( new_size > allocated ) { new_alloc = assign_new_size ( new_size ) ; new_string = new char [ new_alloc ] ; new_string [ 0 ] = 0 ; if ( allocated && cstring ) memcpy ( new_string , cstring , 1 + length ( ) ) ; memcpy ( new_string + length ( ) , suffix , strlen ( suffix ) + 1 ) ; if ( allocated && cstring ) delete [ ] cstring ; cstring = new_string ; allocated = new_alloc ; } else { memcpy ( cstring + length ( ) , suffix , strlen ( suffix ) + 1 ) ; } current_length = new_size - 1 ; }
append a const char * to an existing TiXmlString
append a const char * to an existing TiXmlString
// check if we need to expand // compute new size // allocate new buffer // copy the previous allocated buffer into this one // strcpy (new_string, cstring); // append the suffix. It does exist, otherwize we wouldn't be expanding  // strcat (new_string, suffix); // return previsously allocated buffer if any // update member variables // we know we can safely append the new string // strcat (cstring, suffix);