Changeset 12312


Ignore:
Timestamp:
Apr 5, 2011, 12:55:09 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) Use tr_strndup() instead of tr_strdup() in tr_urlParse() to avoid a couple of strlen() calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r12292 r12312  
    10111011    char *       tmp;
    10121012    char *       pch;
     1013    size_t       host_len;
     1014    size_t       protocol_len;
     1015    const char * host = NULL;
    10131016    const char * protocol = NULL;
    1014     const char * host = NULL;
    10151017    const char * path = NULL;
    10161018
     
    10201022        *pch = '\0';
    10211023        protocol = tmp;
     1024        protocol_len = pch - protocol;
    10221025        pch += 3;
    10231026/*fprintf( stderr, "protocol is [%s]... what's left is [%s]\n", protocol, pch);*/
     
    10261029            const int havePort = pch[n] == ':';
    10271030            host = pch;
     1031            host_len = n;
    10281032            pch += n;
    10291033            *pch++ = '\0';
     
    10541058    if( !err )
    10551059    {
    1056         if( setme_protocol ) *setme_protocol = tr_strdup( protocol );
     1060        if( setme_protocol ) *setme_protocol = tr_strndup( protocol, protocol_len );
    10571061
    10581062        if( setme_host ){ ( (char*)host )[-3] = ':'; *setme_host =
    1059                               tr_strdup( host ); }
     1063                              tr_strndup( host, host_len ); }
    10601064        if( setme_path ){ if( path[0] == '/' ) *setme_path = tr_strdup( path );
    10611065                          else { ( (char*)path )[-1] = '/'; *setme_path = tr_strdup( path - 1 ); } }
Note: See TracChangeset for help on using the changeset viewer.