Convert strdup/free to string
This commit is contained in:
@@ -179,11 +179,7 @@ int main( int argc, char *argv[] )
|
|||||||
char *predict_overwrite = getenv( "MOSH_PREDICTION_OVERWRITE" );
|
char *predict_overwrite = getenv( "MOSH_PREDICTION_OVERWRITE" );
|
||||||
/* can be NULL */
|
/* can be NULL */
|
||||||
|
|
||||||
char *key = strdup( env_key );
|
string key( env_key );
|
||||||
if ( key == NULL ) {
|
|
||||||
perror( "strdup" );
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( unsetenv( "MOSH_KEY" ) < 0 ) {
|
if ( unsetenv( "MOSH_KEY" ) < 0 ) {
|
||||||
perror( "unsetenv" );
|
perror( "unsetenv" );
|
||||||
@@ -195,7 +191,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
try {
|
try {
|
||||||
STMClient client( ip, desired_port, key, predict_mode, verbose, predict_overwrite );
|
STMClient client( ip, desired_port, key.c_str(), predict_mode, verbose, predict_overwrite );
|
||||||
client.init();
|
client.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -221,7 +217,5 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
printf( "[mosh is exiting.]\n" );
|
printf( "[mosh is exiting.]\n" );
|
||||||
|
|
||||||
free( key );
|
|
||||||
|
|
||||||
return !success;
|
return !success;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user