Changeset 8246


Ignore:
Timestamp:
Apr 16, 2009, 7:14:37 PM (13 years ago)
Author:
charles
Message:

(trunk libT) fix long-standing wart of a few public API calls returning strdup'ed char*, rather than a const char* like all the others

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r8242 r8246  
    644644}
    645645
    646 char*
     646const char*
    647647tr_rpcGetWhitelist( const tr_rpc_server * server )
    648648{
    649     return tr_strdup( server->whitelistStr ? server->whitelistStr : "" );
     649    return server->whitelistStr ? server->whitelistStr : "";
    650650}
    651651
     
    676676}
    677677
    678 char*
     678const char*
    679679tr_rpcGetUsername( const tr_rpc_server * server )
    680680{
    681     return tr_strdup( server->username ? server->username : "" );
     681    return server->username ? server->username : "";
    682682}
    683683
     
    694694}
    695695
    696 char*
     696const char*
    697697tr_rpcGetPassword( const tr_rpc_server * server )
    698698{
    699     return tr_strdup( server->password ? server->password : "" );
     699    return server->password ? server->password : "" ;
    700700}
    701701
  • trunk/libtransmission/rpc-server.h

    r8242 r8246  
    4747                                    const char *    whitelist );
    4848
    49 char*           tr_rpcGetWhitelist( const tr_rpc_server * server );
     49const char*     tr_rpcGetWhitelist( const tr_rpc_server * server );
    5050
    5151void            tr_rpcSetPassword( tr_rpc_server * server,
    5252                                   const char *    password );
    5353
    54 char*           tr_rpcGetPassword( const tr_rpc_server * server );
     54const char*     tr_rpcGetPassword( const tr_rpc_server * server );
    5555
    5656void            tr_rpcSetUsername( tr_rpc_server * server,
    5757                                   const char *    username );
    5858
    59 char*           tr_rpcGetUsername( const tr_rpc_server * server );
     59const char*     tr_rpcGetUsername( const tr_rpc_server * server );
    6060
    6161void            tr_rpcSetPasswordEnabled( tr_rpc_server * server,
  • trunk/libtransmission/session.c

    r8244 r8246  
    309309tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
    310310{
    311     int i, n=0;
    312     char * freeme[16];
    313 
    314311    assert( tr_bencIsDict( d ) );
    315312
     
    345342    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_BIND_ADDRESS,         tr_sessionGetRPCBindAddress( s ) );
    346343    tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_ENABLED,              tr_sessionIsRPCEnabled( s ) );
    347     tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_PASSWORD,             freeme[n++] = tr_sessionGetRPCPassword( s ) );
     344    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_PASSWORD,             tr_sessionGetRPCPassword( s ) );
    348345    tr_bencDictAddInt ( d, TR_PREFS_KEY_RPC_PORT,                 tr_sessionGetRPCPort( s ) );
    349     tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_USERNAME,             freeme[n++] = tr_sessionGetRPCUsername( s ) );
    350     tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST,            freeme[n++] = tr_sessionGetRPCWhitelist( s ) );
     346    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_USERNAME,             tr_sessionGetRPCUsername( s ) );
     347    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST,            tr_sessionGetRPCWhitelist( s ) );
    351348    tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED,    tr_sessionGetRPCWhitelistEnabled( s ) );
    352349    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED,        tr_sessionUsesAltSpeed( s ) );
     
    364361    tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV6,
    365362                        tr_ntop_non_ts( tr_socketListGetType( tr_getSessionBindSockets( s ), TR_AF_INET6 ) ) );
    366 
    367     for( i=0; i<n; ++i )
    368         tr_free( freeme[i] );
    369363}
    370364
     
    18591853}
    18601854
    1861 char*
     1855const char*
    18621856tr_sessionGetRPCWhitelist( const tr_session * session )
    18631857{
     
    18941888}
    18951889
    1896 char*
     1890const char*
    18971891tr_sessionGetRPCPassword( const tr_session * session )
    18981892{
     
    19111905}
    19121906
    1913 char*
     1907const char*
    19141908tr_sessionGetRPCUsername( const tr_session * session )
    19151909{
  • trunk/libtransmission/transmission.h

    r8242 r8246  
    374374
    375375/** @brief get the Access Control List for allowing/denying RPC requests.
    376     @return a comma-separated string of whitelist domains.  tr_free() when done.
     376    @return a comma-separated string of whitelist domains.
    377377    @see tr_sessionInit
    378378    @see tr_sessionSetRPCWhitelist */
    379 char* tr_sessionGetRPCWhitelist( const tr_session * );
     379const char* tr_sessionGetRPCWhitelist( const tr_session * );
    380380
    381381void  tr_sessionSetRPCWhitelistEnabled( tr_session * session,
     
    391391
    392392/** @brief get the password used to restrict RPC requests.
    393     @return the password string. tr_free() when done.
     393    @return the password string.
    394394    @see tr_sessionInit()
    395395    @see tr_sessionSetRPCPassword() */
    396 char* tr_sessionGetRPCPassword( const tr_session * session );
    397 
    398 char* tr_sessionGetRPCUsername( const tr_session * session  );
     396const char* tr_sessionGetRPCPassword( const tr_session * session );
     397
     398const char* tr_sessionGetRPCUsername( const tr_session * session  );
    399399
    400400void  tr_sessionSetRPCPasswordEnabled( tr_session * session,
Note: See TracChangeset for help on using the changeset viewer.