From 670cc0e86f59421f55019a14c180ac323803faf6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 18 Jul 2023 16:44:30 +0300 Subject: [PATCH 21/23] Free actions on ACTION_UNUSED_? slots See osdn #48416 Signed-off-by: Marko Lindqvist --- common/actions.c | 8 ++++---- common/actions.h | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/common/actions.c b/common/actions.c index 68d78ade52..ea90cac973 100644 --- a/common/actions.c +++ b/common/actions.c @@ -1547,9 +1547,9 @@ void actions_init(void) hard_code_actions(); /* Initialize the action enabler list */ - action_iterate(act) { + action_iterate_all(act) { action_enablers_by_action[act] = action_enabler_list_new(); - } action_iterate_end; + } action_iterate_all_end; /* Initialize action obligatory hard requirements. */ @@ -1609,7 +1609,7 @@ void actions_free(void) /* Don't consider the actions to be initialized any longer. */ actions_initialized = FALSE; - action_iterate(act) { + action_iterate_all(act) { action_enabler_list_iterate(action_enablers_by_action[act], enabler) { action_enabler_free(enabler); } action_enabler_list_iterate_end; @@ -1617,7 +1617,7 @@ void actions_free(void) action_enabler_list_destroy(action_enablers_by_action[act]); FC_FREE(actions[act]); - } action_iterate_end; + } action_iterate_all_end; /* Free the obligatory hard action requirements. */ for (i = 0; i < ACTRES_NONE; i++) { diff --git a/common/actions.h b/common/actions.h index 22124f91fb..d586c85dde 100644 --- a/common/actions.h +++ b/common/actions.h @@ -444,15 +444,23 @@ struct action_enabler } \ } action_enabler_list_iterate_end -#define action_iterate(_act_) \ +#define action_iterate_all(_act_) \ { \ action_id _act_; \ - for (_act_ = 0; _act_ < NUM_ACTIONS; _act_++) { \ + for (_act_ = 0; _act_ < NUM_ACTIONS; _act_++) { + +#define action_iterate_all_end \ + } \ +} + +#define action_iterate(_act_) \ +{ \ + action_iterate_all(_act_) { \ if (_act_ != ACTION_UNUSED_1 && _act_ != ACTION_UNUSED_2) { -#define action_iterate_end \ - } \ - } \ +#define action_iterate_end \ + } \ + } action_iterate_all_end; \ } /* Get 'struct action_id_list' and related functions: */ -- 2.40.1