mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Accept empty lists
This commit is contained in:
parent
fa5a496629
commit
76a8f79211
3 changed files with 8 additions and 8 deletions
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
QUIET?=@
|
||||
CFLAGS?=-Wall -Wextra -O3
|
||||
CFLAGS?=-Wall -Wextra -O3 -g
|
||||
VERSION?=0.14.1
|
||||
|
||||
PROGRAM=simpleswitcher
|
||||
|
|
|
@ -109,9 +109,6 @@ SwitcherMode dmenu_switcher_dialog ( char **input )
|
|||
// act as a launcher
|
||||
char **list = get_dmenu( );
|
||||
|
||||
if ( list == NULL ) {
|
||||
return retv;
|
||||
}
|
||||
|
||||
int shift=0;
|
||||
int selected_line = 0;
|
||||
|
@ -125,11 +122,11 @@ SwitcherMode dmenu_switcher_dialog ( char **input )
|
|||
fputs( *input, stdout );
|
||||
}
|
||||
|
||||
for ( unsigned int i=0; list[i] != NULL; i++ ) {
|
||||
for ( unsigned int i=0; list != NULL && list[i] != NULL; i++ ) {
|
||||
free( list[i] );
|
||||
}
|
||||
|
||||
free( list );
|
||||
if(list != NULL) free( list );
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ const char *cache_dir = NULL;
|
|||
|
||||
void* allocate( unsigned long bytes )
|
||||
{
|
||||
if(bytes == 0) return NULL;
|
||||
void *ptr = malloc( bytes );
|
||||
|
||||
if ( !ptr ) {
|
||||
|
@ -92,12 +93,14 @@ void* allocate( unsigned long bytes )
|
|||
}
|
||||
void* allocate_clear( unsigned long bytes )
|
||||
{
|
||||
if(bytes == 0) return NULL;
|
||||
void *ptr = allocate( bytes );
|
||||
memset( ptr, 0, bytes );
|
||||
return ptr;
|
||||
}
|
||||
void* reallocate( void *ptr, unsigned long bytes )
|
||||
{
|
||||
if(bytes == 0) return NULL;
|
||||
ptr = realloc( ptr, bytes );
|
||||
|
||||
if ( !ptr ) {
|
||||
|
@ -775,7 +778,7 @@ MenuReturn menu( char **lines, char **input, char *prompt, Time *time, int *shif
|
|||
int last_offset = 0;
|
||||
unsigned int selected = 0;
|
||||
|
||||
for ( ; lines[num_lines]; num_lines++ );
|
||||
for ( ; lines != NULL && lines[num_lines]; num_lines++ );
|
||||
|
||||
unsigned int max_lines = MIN( config.menu_lines, num_lines );
|
||||
|
||||
|
@ -983,7 +986,7 @@ MenuReturn menu( char **lines, char **input, char *prompt, Time *time, int *shif
|
|||
if ( shift != NULL )
|
||||
( *shift ) = ( ( ev.xkey.state&ShiftMask ) == ShiftMask );
|
||||
|
||||
if ( filtered[selected] ) {
|
||||
if ( filtered && filtered[selected] ) {
|
||||
retv = MENU_OK;
|
||||
*selected_line = line_map[selected];
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue