1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[Mode] Make the name field a pointer instead of a fixed 32char array.

This commit is contained in:
Dave Davenport 2017-04-21 09:37:03 +02:00
parent 5edc739848
commit 01159b29f0
2 changed files with 5 additions and 4 deletions

View file

@ -31,7 +31,7 @@
#include <gmodule.h> #include <gmodule.h>
/** ABI version to check if loaded plugin is compatible. */ /** ABI version to check if loaded plugin is compatible. */
#define ABI_VERSION 0x00000004 #define ABI_VERSION 0x00000005
/** /**
* @param data Pointer to #Mode object. * @param data Pointer to #Mode object.
@ -143,7 +143,7 @@ struct rofi_mode
/** Used for external plugins. */ /** Used for external plugins. */
unsigned int abi_version; unsigned int abi_version;
/** Name (max 31 char long) */ /** Name (max 31 char long) */
char name[32]; char *name;
char cfg_name_key[128]; char cfg_name_key[128];
char *display_name; char *display_name;

View file

@ -91,6 +91,7 @@ static void script_switcher_free ( Mode *sw )
if ( sw == NULL ) { if ( sw == NULL ) {
return; return;
} }
g_free ( sw->name );
g_free ( sw->ed ); g_free ( sw->ed );
g_free ( sw ); g_free ( sw );
} }
@ -182,7 +183,7 @@ Mode *script_switcher_parse_setup ( const char *str )
const char *const sep = ":"; const char *const sep = ":";
for ( char *token = strtok_r ( parse, sep, &endp ); token != NULL; token = strtok_r ( NULL, sep, &endp ) ) { for ( char *token = strtok_r ( parse, sep, &endp ); token != NULL; token = strtok_r ( NULL, sep, &endp ) ) {
if ( index == 0 ) { if ( index == 0 ) {
g_strlcpy ( sw->name, token, 32 ); sw->name = g_strdup ( token );
} }
else if ( index == 1 ) { else if ( index == 1 ) {
sw->ed = (void *) rofi_expand_path ( token ); sw->ed = (void *) rofi_expand_path ( token );
@ -203,7 +204,7 @@ Mode *script_switcher_parse_setup ( const char *str )
return sw; return sw;
} }
g_warning ( "The script command '%s' has %u options, but needs 2: <name>:<script>.", str, index ); fprintf ( stderr, "The script command '%s' has %u options, but needs 2: <name>:<script>.", str, index );
script_switcher_free ( sw ); script_switcher_free ( sw );
return NULL; return NULL;
} }