Const correctness and const-ref in Crypto and elsewhere.
This commit is contained in:
@@ -96,7 +96,7 @@ string Packet::tostring( Session *session )
|
||||
return session->encrypt( Message( Nonce( direction_seq ), timestamps + payload ) );
|
||||
}
|
||||
|
||||
Packet Connection::new_packet( string &s_payload )
|
||||
Packet Connection::new_packet( const string &s_payload )
|
||||
{
|
||||
uint16_t outgoing_timestamp_reply = -1;
|
||||
|
||||
@@ -391,7 +391,7 @@ Connection::Connection( const char *key_str, const char *ip, const char *port )
|
||||
set_MTU( remote_addr.sa.sa_family );
|
||||
}
|
||||
|
||||
void Connection::send( string s )
|
||||
void Connection::send( const string & s )
|
||||
{
|
||||
if ( !has_remote_addr ) {
|
||||
return;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Network {
|
||||
string payload;
|
||||
|
||||
Packet( Direction s_direction,
|
||||
uint16_t s_timestamp, uint16_t s_timestamp_reply, string s_payload )
|
||||
uint16_t s_timestamp, uint16_t s_timestamp_reply, const string & s_payload )
|
||||
: seq( Crypto::unique() ), direction( s_direction ),
|
||||
timestamp( s_timestamp ), timestamp_reply( s_timestamp_reply ), payload( s_payload )
|
||||
{}
|
||||
@@ -190,7 +190,7 @@ namespace Network {
|
||||
bool have_send_exception;
|
||||
NetworkException send_exception;
|
||||
|
||||
Packet new_packet( string &s_payload );
|
||||
Packet new_packet( const string &s_payload );
|
||||
|
||||
void hop_port( void );
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Network {
|
||||
Connection( const char *desired_ip, const char *desired_port ); /* server */
|
||||
Connection( const char *key_str, const char *ip, const char *port ); /* client */
|
||||
|
||||
void send( string s );
|
||||
void send( const string & s );
|
||||
string recv( void );
|
||||
const std::vector< int > fds( void ) const;
|
||||
int get_MTU( void ) const { return MTU; }
|
||||
|
||||
@@ -72,7 +72,7 @@ string Fragment::tostring( void )
|
||||
return ret;
|
||||
}
|
||||
|
||||
Fragment::Fragment( string &x )
|
||||
Fragment::Fragment( const string &x )
|
||||
: id( -1 ), fragment_num( -1 ), final( false ), initialized( true ),
|
||||
contents()
|
||||
{
|
||||
|
||||
@@ -61,12 +61,12 @@ namespace Network {
|
||||
: id( -1 ), fragment_num( -1 ), final( false ), initialized( false ), contents()
|
||||
{}
|
||||
|
||||
Fragment( uint64_t s_id, uint16_t s_fragment_num, bool s_final, string s_contents )
|
||||
Fragment( uint64_t s_id, uint16_t s_fragment_num, bool s_final, const string & s_contents )
|
||||
: id( s_id ), fragment_num( s_fragment_num ), final( s_final ), initialized( true ),
|
||||
contents( s_contents )
|
||||
{}
|
||||
|
||||
Fragment( string &x );
|
||||
Fragment( const string &x );
|
||||
|
||||
string tostring( void );
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ void TransportSender<MyState>::add_sent_state( uint64_t the_timestamp, uint64_t
|
||||
}
|
||||
|
||||
template <class MyState>
|
||||
void TransportSender<MyState>::send_to_receiver( string diff )
|
||||
void TransportSender<MyState>::send_to_receiver( const string & diff )
|
||||
{
|
||||
uint64_t new_num;
|
||||
if ( current_state == sent_states.back().state ) { /* previously sent */
|
||||
@@ -310,7 +310,7 @@ const string TransportSender<MyState>::make_chaff( void )
|
||||
}
|
||||
|
||||
template <class MyState>
|
||||
void TransportSender<MyState>::send_in_fragments( string diff, uint64_t new_num )
|
||||
void TransportSender<MyState>::send_in_fragments( const string & diff, uint64_t new_num )
|
||||
{
|
||||
Instruction inst;
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ namespace Network {
|
||||
void update_assumed_receiver_state( void );
|
||||
void attempt_prospective_resend_optimization( string &proposed_diff );
|
||||
void rationalize_states( void );
|
||||
void send_to_receiver( string diff );
|
||||
void send_to_receiver( const string & diff );
|
||||
void send_empty_ack( void );
|
||||
void send_in_fragments( string diff, uint64_t new_num );
|
||||
void send_in_fragments( const string & diff, uint64_t new_num );
|
||||
void add_sent_state( uint64_t the_timestamp, uint64_t num, MyState &state );
|
||||
|
||||
/* state of sender */
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Network {
|
||||
uint64_t num;
|
||||
State state;
|
||||
|
||||
TimestampedState( uint64_t s_timestamp, uint64_t s_num, State &s_state )
|
||||
TimestampedState( uint64_t s_timestamp, uint64_t s_num, const State &s_state )
|
||||
: timestamp( s_timestamp ), num( s_num ), state( s_state )
|
||||
{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user