This commit is contained in:
Qball Cow 2014-01-21 10:35:59 +01:00
parent ef8d444dd2
commit 0068618573
2 changed files with 22 additions and 46 deletions

View File

@ -354,10 +354,6 @@ void winlist_free( winlist *l )
free( l->data );
free( l );
}
void winlist_empty_2d( winlist *l )
{
while ( l->len > 0 ) winlist_free( l->data[--( l->len )] );
}
int winlist_find( winlist *l, Window w )
{
// iterate backwards. theory is: windows most often accessed will be
@ -369,23 +365,6 @@ int winlist_find( winlist *l, Window w )
return -1;
}
int winlist_forget( winlist *l, Window w )
{
int i, j;
for ( i = 0, j = 0; i < l->len; i++, j++ ) {
l->array[j] = l->array[i];
l->data[j] = l->data[i];
if ( l->array[i] == w ) {
free( l->data[i] );
j--;
}
}
l->len -= ( i-j );
return j != i ?1:0;
}
#define CLIENTTITLE 100
#define CLIENTCLASS 50
@ -1273,7 +1252,17 @@ void help()
}
}
inline int program_end()
{
winlist_free( cache_xattr );
winlist_free( cache_client );
#ifdef I3
if ( i3_socket_path != NULL ) free( i3_socket_path );
#endif
return EXIT_SUCCESS;
}
int main( int argc, char *argv[] )
@ -1357,32 +1346,17 @@ int main( int argc, char *argv[] )
// flags to run immediately and exit
if ( find_arg( ac, av, "-now" ) >= 0 ) {
run_switcher( NOFORK, WINDOW_SWITCHER );
#ifdef I3
if ( i3_socket_path != NULL ) free( i3_socket_path );
#endif
exit( EXIT_SUCCESS );
return program_end();
}
if ( find_arg( ac, av, "-rnow" ) >= 0 ) {
run_switcher( NOFORK, RUN_DIALOG );
#ifdef I3
if ( i3_socket_path != NULL ) free( i3_socket_path );
#endif
exit( EXIT_SUCCESS );
return program_end();
}
if ( find_arg( ac, av, "-snow" ) >= 0 ) {
run_switcher( NOFORK, SSH_DIALOG );
#ifdef I3
if ( i3_socket_path != NULL ) free( i3_socket_path );
#endif
exit( EXIT_SUCCESS );
return program_end();
}
// in background mode from here on
@ -1413,10 +1387,5 @@ int main( int argc, char *argv[] )
if ( ev.type == KeyPress ) handle_keypress( &ev );
}
#ifdef I3
if ( i3_socket_path != NULL ) free( i3_socket_path );
#endif
return EXIT_SUCCESS;
return program_end();
}

View File

@ -184,11 +184,18 @@ static char ** get_ssh ( )
for ( stop=start; isalnum( buffer[stop] ); stop++ );
int found = 0;
// This is a nice little penalty, but doable? time will tell.
// given num_favorites is max 25.
for ( int j = 0; found == 0 && j < num_favorites; j++ ) {
if ( strncasecmp( &buffer[start], retv[j],stop-start ) == 0 ) found = 1;
}
if ( found == 1 ) continue;
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
retv[index] = strndup( &buffer[start], stop-start );
retv[index+1] = NULL;
index++;
num_favorites++;
}
}