Scripts_directory is now dynamically allocated

This commit is contained in:
Thomas Bernard 2019-01-15 13:23:00 +01:00
parent b3baa57a36
commit f90a2331dd
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
3 changed files with 10 additions and 6 deletions

View File

@ -1289,6 +1289,7 @@ void Program_shutdown(void)
{
FREE_POINTER(Config.Bookmark_directory[i]);
}
FREE_POINTER(Config.Scripts_directory);
Uninit_text();

View File

@ -993,16 +993,19 @@ int Load_INI(T_Config * conf)
}
// Optional, Location of last directory used for Lua scripts browsing (>=2.3)
conf->Scripts_directory[0]='\0';
free(conf->Scripts_directory);
conf->Scripts_directory = NULL;
if (!Load_INI_get_string (file,buffer,"Scripts_directory",value_label, 1))
{
strcpy(conf->Scripts_directory,value_label);
if (value_label[0] != '\0')
conf->Scripts_directory = strdup(value_label);
}
if (conf->Scripts_directory[0]=='\0')
if (conf->Scripts_directory == NULL)
{
// Default when empty:
Realpath(Data_directory, conf->Scripts_directory);
Append_path(conf->Scripts_directory, SCRIPTS_SUBDIRECTORY, NULL);
char * path = Realpath(Data_directory, NULL);
conf->Scripts_directory = Filepath_append_to_dir(path, SCRIPTS_SUBDIRECTORY);
free(path);
}
conf->Allow_multi_shortcuts=0;

View File

@ -375,7 +375,7 @@ typedef struct
byte Sync_views; ///< Boolean, true when the Main and Spare should share their viewport settings.
byte Stylus_mode; ///< Boolean, true to tweak some tools (eg:Curve) for single-button stylus.
word Swap_buttons; ///< Sets which key swaps mouse buttons : 0=none, or GFX2_MOD_CTRL, or GFX2_MOD_ALT.
char Scripts_directory[MAX_PATH_CHARACTERS];///< Full pathname of directory for Lua scripts
char * Scripts_directory; ///< Full pathname of directory for Lua scripts
byte Allow_multi_shortcuts; ///< Boolean, true if the same key combination can trigger multiple shortcuts.
byte Tilemap_allow_flipped_x; ///< Boolean, true if the Tilemap tool should detect x-flipped tiles.
byte Tilemap_allow_flipped_y; ///< Boolean, true if the Tilemap tool should detect y-flipped tiles.