MINOR: tree-wide: use free_acl_cond() where relevant

Now that we have free_acl_cond(cond) function that does cond prune then
frees cond, replace all occurences of this pattern:

   | prune_acl_cond(cond)
   | free(cond)

with:

   | free_acl_cond(cond)
This commit is contained in:
Aurelien DARRAGON 2023-05-11 12:29:51 +02:00 committed by Christopher Faulet
parent cd9aff1321
commit c610095258
7 changed files with 16 additions and 47 deletions

View File

@ -528,10 +528,7 @@ void flt_ot_conf_scope_free(struct flt_ot_conf_scope **ptr)
FLT_OT_LIST_DEL(&(acl->list));
FLT_OT_FREE(acl);
}
if ((*ptr)->cond != NULL) {
prune_acl_cond((*ptr)->cond);
FLT_OT_FREE((*ptr)->cond);
}
free_acl_cond((*ptr)->cond);
FLT_OT_LIST_DESTROY(context, &((*ptr)->contexts));
FLT_OT_LIST_DESTROY(span, &((*ptr)->spans));
FLT_OT_LIST_DESTROY(str, &((*ptr)->finish));

View File

@ -1007,8 +1007,7 @@ struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl,
out_free_term:
free(cur_term);
out_free_suite:
prune_acl_cond(cond);
free(cond);
free_acl_cond(cond);
out_return:
return NULL;
}
@ -1337,6 +1336,7 @@ void acl_dump_kwd(void)
}
}
/* Purge everything in the acl_cond <cond>, then free <cond> */
void free_acl_cond(struct acl_cond *cond)
{
struct acl_term_suite *suite, *suiteb;

View File

@ -1408,9 +1408,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
rule->file = strdup(file);
if (!rule->file) {
use_backend_alloc_error:
if (cond)
prune_acl_cond(cond);
ha_free(&cond);
free_acl_cond(cond);
if (rule)
ha_free(&(rule->be.name));
ha_free(&rule);
@ -1464,9 +1462,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
rule->file = strdup(file);
if (!rule->file) {
use_server_alloc_error:
if (cond)
prune_acl_cond(cond);
ha_free(&cond);
free_acl_cond(cond);
if (rule)
ha_free(&(rule->srv.name));
ha_free(&rule);
@ -1510,9 +1506,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
rule = calloc(1, sizeof(*rule));
if (!rule) {
if (cond)
prune_acl_cond(cond);
ha_free(&cond);
free_acl_cond(cond);
goto alloc_error;
}
rule->cond = cond;
@ -1678,9 +1672,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
rule = calloc(1, sizeof(*rule));
if (!rule) {
if (cond)
prune_acl_cond(cond);
ha_free(&cond);
free_acl_cond(cond);
goto alloc_error;
}
rule->cond = cond;
@ -1733,9 +1725,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
rule = calloc(1, sizeof(*rule));
if (!rule) {
if (cond)
prune_acl_cond(cond);
ha_free(&cond);
free_acl_cond(cond);
goto alloc_error;
}
rule->cond = cond;

View File

@ -125,10 +125,7 @@ static void fcgi_release_rule_conf(struct fcgi_rule_conf *rule)
return;
free(rule->name);
free(rule->value);
if (rule->cond) {
prune_acl_cond(rule->cond);
free(rule->cond);
}
free_acl_cond(rule->cond);
free(rule);
}
@ -760,10 +757,7 @@ static int fcgi_app_add_rule(struct fcgi_app *curapp, enum fcgi_rule_type type,
free(rule->value);
free(rule);
}
if (cond) {
prune_acl_cond(cond);
free(cond);
}
free_acl_cond(cond);
memprintf(err, "out of memory");
return 0;
}

View File

@ -141,10 +141,7 @@ spoe_release_message(struct spoe_message *msg)
prune_acl(acl);
free(acl);
}
if (msg->cond) {
prune_acl_cond(msg->cond);
free(msg->cond);
}
free_acl_cond(msg->cond);
free(msg);
}

View File

@ -322,10 +322,7 @@ void http_free_redirect_rule(struct redirect_rule *rdr)
{
struct logformat_node *lf, *lfb;
if (rdr->cond) {
prune_acl_cond(rdr->cond);
free(rdr->cond);
}
free_acl_cond(rdr->cond);
free(rdr->rdr_str);
free(rdr->cookie_str);
list_for_each_entry_safe(lf, lfb, &rdr->rdr_fmt, list) {
@ -519,8 +516,7 @@ struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, st
http_free_redirect_rule(rule);
else if (cond) {
/* rule not yet allocated, but cond already is */
prune_acl_cond(cond);
free(cond);
free_acl_cond(cond);
}
return NULL;

View File

@ -200,8 +200,7 @@ void free_proxy(struct proxy *p)
list_for_each_entry_safe(cond, condb, &p->mon_fail_cond, list) {
LIST_DELETE(&cond->list);
prune_acl_cond(cond);
free(cond);
free_acl_cond(cond);
}
EXTRA_COUNTERS_FREE(p->extra_counters_fe);
@ -215,7 +214,7 @@ void free_proxy(struct proxy *p)
list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) {
LIST_DELETE(&srule->list);
prune_acl_cond(srule->cond);
free_acl_cond(srule->cond);
list_for_each_entry_safe(lf, lfb, &srule->expr, list) {
LIST_DELETE(&lf->list);
release_sample_expr(lf->expr);
@ -223,16 +222,12 @@ void free_proxy(struct proxy *p)
free(lf);
}
free(srule->file);
free(srule->cond);
free(srule);
}
list_for_each_entry_safe(rule, ruleb, &p->switching_rules, list) {
LIST_DELETE(&rule->list);
if (rule->cond) {
prune_acl_cond(rule->cond);
free(rule->cond);
}
free_acl_cond(rule->cond);
free(rule->file);
free(rule);
}