Changeset 8689


Ignore:
Timestamp:
Jun 14, 2009, 2:39:51 PM (13 years ago)
Author:
charles
Message:

(trunk libT) avoid an extra malloc/free when sending the opening handshake message

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/crypto.c

    r8553 r8689  
    350350
    351351void
    352 tr_cryptoRandBuf( unsigned char *buf,
    353                   size_t         len )
    354 {
    355     if( RAND_pseudo_bytes ( buf, len ) != 1 )
     352tr_cryptoRandBuf( void * buf, size_t len )
     353{
     354    if( RAND_pseudo_bytes ( (unsigned char*)buf, len ) != 1 )
    356355        logErrorFromSSL( );
    357356}
  • trunk/libtransmission/crypto.h

    r8561 r8689  
    9999
    100100/** Fills a buffer with random bytes */
    101 void           tr_cryptoRandBuf( unsigned char *buf,
    102                                  size_t         len );
     101void           tr_cryptoRandBuf( void * buf, size_t len );
    103102
    104103char*          tr_ssha1( const void * plaintext );
  • trunk/libtransmission/handshake.c

    r8685 r8689  
    333333    int               len;
    334334    const uint8_t *   public_key;
    335     struct evbuffer * outbuf = evbuffer_new( );
    336     uint8_t           pad_a[PadA_MAXLEN];
     335    char              outbuf[ KEY_LEN + PadA_MAXLEN ], *walk=outbuf;
    337336
    338337    /* add our public key (Ya) */
     
    340339    assert( len == KEY_LEN );
    341340    assert( public_key );
    342     evbuffer_add( outbuf, public_key, len );
     341    memcpy( walk, public_key, len );
     342    walk += len;
    343343
    344344    /* add some bullshit padding */
    345345    len = tr_cryptoRandInt( PadA_MAXLEN );
    346     tr_cryptoRandBuf( pad_a, len );
    347     evbuffer_add( outbuf, pad_a, len );
     346    tr_cryptoRandBuf( walk, len );
     347    walk += len;
    348348
    349349    /* send it */
    350350    setReadState( handshake, AWAITING_YB );
    351     tr_peerIoWriteBuf( handshake->io, outbuf, FALSE );
    352 
    353     /* cleanup */
    354     evbuffer_free( outbuf );
     351    tr_peerIoWrite( handshake->io, outbuf, walk-outbuf, FALSE );
    355352}
    356353
  • trunk/libtransmission/metainfo.c

    r8688 r8689  
    244244        memcpy( walk, suffix, suffix_len ); walk += suffix_len;
    245245        *walk++ = '\0';
    246         assert( walk - scrape == alloc_len );
     246        assert( walk - scrape == (int)alloc_len );
    247247    }
    248248
Note: See TracChangeset for help on using the changeset viewer.