Ignore:
Timestamp:
Apr 1, 2011, 3:23:55 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) avoid an unnecessary malloc/free in tr_urlIsValidTracker() and tr_urlIsValid()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r12247 r12292  
    967967{
    968968    bool valid;
    969     char * scheme = NULL;
    970969    const int len = url ? strlen(url) : 0;
    971970
    972971    valid = isValidURLChars( url, len )
    973          && !tr_urlParse( url, len, &scheme, NULL, NULL, NULL )
    974          && ( scheme != NULL )
    975          && ( !strcmp(scheme,"http") || !strcmp(scheme,"https") || !strcmp(scheme,"udp") );
    976 
    977     tr_free( scheme );
     972         && !tr_urlParse( url, len, NULL, NULL, NULL, NULL )
     973         && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"udp://",6) );
     974
    978975    return valid;
    979976}
     
    984981{
    985982    bool valid;
    986     char * scheme = NULL;
    987983    if( ( url_len < 0 ) && ( url != NULL ) )
    988984        url_len = strlen( url );
    989985
    990986    valid = isValidURLChars( url, url_len )
    991          && !tr_urlParse( url, url_len, &scheme, NULL, NULL, NULL )
    992          && ( scheme != NULL )
    993          && ( !strcmp(scheme,"http") || !strcmp(scheme,"https") || !strcmp(scheme,"ftp") || !strcmp(scheme,"sftp") );
    994 
    995     tr_free( scheme );
     987         && !tr_urlParse( url, url_len, NULL, NULL, NULL, NULL )
     988         && ( !memcmp(url,"http://",7) || !memcmp(url,"https://",8) || !memcmp(url,"ftp://",6) || !memcmp(url,"sftp://",7) );
     989
    996990    return valid;
    997991}
Note: See TracChangeset for help on using the changeset viewer.