Skip to content

Commit

Permalink
config: don't pointlessly copy the palette string
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpapersonic committed Sep 22, 2024
1 parent 9c8cc43 commit 6968634
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions schism/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,10 @@ void cfg_init_dir(void)
static const char palette_trans[64] = ".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
static void cfg_load_palette(cfg_file_t *cfg)
{
char palette_text[49] = "";
cfg_get_string(cfg, "General", "palette_cur", palette_text, 48, "");
const char *palette_text = cfg_get_string(cfg, "General", "palette_cur", NULL, 0, NULL);

if(palette_text[0]) {
if (palette_text && strlen(palette_text) >= 48)
set_palette_from_string(palette_text);
}

palette_load_preset(cfg_get_number(cfg, "General", "palette", 2));
}
Expand All @@ -150,11 +148,9 @@ static void cfg_save_palette(cfg_file_t *cfg)
{
cfg_set_number(cfg, "General", "palette", current_palette_index);

if(current_palette_index == 0) {
char palette_text[49] = "";
palette_to_string(current_palette_index, palette_text);
cfg_set_string(cfg, "General", "palette_cur", palette_text);
}
char palette_text[48 + 1] = {0};
palette_to_string(0, palette_text);
cfg_set_string(cfg, "General", "palette_cur", palette_text);
}

/* --------------------------------------------------------------------------------------------------------- */
Expand Down

0 comments on commit 6968634

Please sign in to comment.