Skip to content

Commit

Permalink
legiond: reset config on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
st0nie committed Apr 14, 2024
1 parent 15cd63a commit f43ba2f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions extra/service/legiond/modules/parseconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,58 @@ static int handler(void *user, const char *section, const char *name,
return 1;
}

static void reset(const char *p)
{
if (p) {
free((char *)p);
}
}

static void init_config(LEGIOND_CONFIG *config)
{
static bool reload = false;
config->fan_control = false;
config->cpu_control = false;
if (reload) {
reset(config->gpu_control);
reset(config->cpu_ac_q);
reset(config->cpu_bat_q);
reset(config->cpu_ac_b);
reset(config->cpu_bat_b);
reset(config->cpu_ac_bp);
reset(config->cpu_bat_bp);
reset(config->cpu_ac_p);
reset(config->gpu_tdp_ac_q);
reset(config->gpu_tdp_bat_q);
reset(config->gpu_tdp_ac_b);
reset(config->gpu_tdp_bat_b);
reset(config->gpu_tdp_ac_bp);
reset(config->gpu_tdp_bat_bp);
reset(config->gpu_tdp_ac_p);
} else {
reload = true;
}

config->gpu_control = NULL;
config->cpu_ac_q = NULL;
config->cpu_bat_q = NULL;
config->cpu_ac_b = NULL;
config->cpu_bat_b = NULL;
config->cpu_ac_bp = NULL;
config->cpu_bat_bp = NULL;
config->cpu_ac_p = NULL;
config->gpu_tdp_ac_q = NULL;
config->gpu_tdp_bat_q = NULL;
config->gpu_tdp_ac_b = NULL;
config->gpu_tdp_bat_b = NULL;
config->gpu_tdp_ac_bp = NULL;
config->gpu_tdp_bat_bp = NULL;
config->gpu_tdp_ac_p = NULL;
}

extern int parseconf(LEGIOND_CONFIG *config)
{
init_config(config);
if (ini_parse(config_path, handler, config)) {
printf("Unable to parse config\n");
return 1;
Expand Down

0 comments on commit f43ba2f

Please sign in to comment.