Changeset 3995


Ignore:
Timestamp:
Nov 27, 2007, 4:11:39 AM (15 years ago)
Author:
charles
Message:

reimplement tr_buildPath() using struct evbuffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r3971 r3995  
    464464tr_buildPath ( char *buf, size_t buflen, const char *first_element, ... )
    465465{
     466    struct evbuffer * evbuf = evbuffer_new( );
     467    const char * element = first_element;
    466468    va_list vl;
    467     char* walk = buf;
    468     const char * element = first_element;
    469 
    470     if( first_element == NULL )
    471         return;
    472 
    473469    va_start( vl, first_element );
    474     for( ;; ) {
    475         const size_t n = strlen( element );
    476         memcpy( walk, element, n );
    477         walk += n;
     470    while( element ) {
     471        if( EVBUFFER_LENGTH(evbuf) )
     472            evbuffer_add_printf( evbuf, "%c", TR_PATH_DELIMITER );
     473        evbuffer_add_printf( evbuf, "%s", element );
    478474        element = (const char*) va_arg( vl, const char* );
    479         if( element == NULL )
    480             break;
    481         *walk++ = TR_PATH_DELIMITER;
    482     }
    483     *walk = '\0';
    484     assert( walk-buf <= (int)buflen );
     475    }
     476    strlcpy( buf, (char*)EVBUFFER_DATA(evbuf), buflen );
     477    evbuffer_free( evbuf );
    485478}
    486479
Note: See TracChangeset for help on using the changeset viewer.