Convert new/delete to shared_ptr.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "pty_compat.h"
|
||||
#include "networktransport-impl.h"
|
||||
#include "select.h"
|
||||
#include "shared.h"
|
||||
|
||||
using namespace Network;
|
||||
|
||||
@@ -49,9 +50,8 @@ int main( int argc, char *argv[] )
|
||||
char *port;
|
||||
|
||||
UserStream me, remote;
|
||||
|
||||
Transport<UserStream, UserStream> *n;
|
||||
|
||||
typedef shared::shared_ptr<Transport<UserStream, UserStream> > NetworkPointer;
|
||||
Transport<UserStream, UserStream> *raw_n;
|
||||
try {
|
||||
if ( argc > 1 ) {
|
||||
server = false;
|
||||
@@ -61,15 +61,16 @@ int main( int argc, char *argv[] )
|
||||
ip = argv[ 2 ];
|
||||
port = argv[ 3 ];
|
||||
|
||||
n = new Transport<UserStream, UserStream>( me, remote, key, ip, port );
|
||||
raw_n = new Transport<UserStream, UserStream>( me, remote, key, ip, port );
|
||||
} else {
|
||||
n = new Transport<UserStream, UserStream>( me, remote, NULL, NULL );
|
||||
raw_n = new Transport<UserStream, UserStream>( me, remote, NULL, NULL );
|
||||
}
|
||||
fprintf( stderr, "Port bound is %s, key is %s\n", n->port().c_str(), n->get_key().c_str() );
|
||||
} catch ( const std::exception &e ) {
|
||||
fprintf( stderr, "Fatal startup error: %s\n", e.what() );
|
||||
exit( 1 );
|
||||
}
|
||||
NetworkPointer n( raw_n );
|
||||
fprintf( stderr, "Port bound is %s, key is %s\n", n->port().c_str(), n->get_key().c_str() );
|
||||
|
||||
if ( server ) {
|
||||
Select &sel = Select::get_instance();
|
||||
@@ -168,6 +169,4 @@ int main( int argc, char *argv[] )
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
delete n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user