mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 19:16:56 +00:00
MINOR: proxy: add free_logformat_list() helper function
There are multiple places inside free_proxy() where we need to perform the exact same operation: freeing a logformat list which includes freeing every member. To prevent code duplication, we add the free_logformat_list() function that takes such list as parameter and does all the freeing job on its own.
This commit is contained in:
parent
8f878d5969
commit
481e9317e3
51
src/proxy.c
51
src/proxy.c
@ -177,6 +177,18 @@ void free_stick_rules(struct list *rules)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_logformat_list(struct list *lfs)
|
||||||
|
{
|
||||||
|
struct logformat_node *lf, *lfb;
|
||||||
|
|
||||||
|
list_for_each_entry_safe(lf, lfb, lfs, list) {
|
||||||
|
LIST_DELETE(&lf->list);
|
||||||
|
release_sample_expr(lf->expr);
|
||||||
|
free(lf->arg);
|
||||||
|
free(lf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void free_proxy(struct proxy *p)
|
void free_proxy(struct proxy *p)
|
||||||
{
|
{
|
||||||
struct server *s;
|
struct server *s;
|
||||||
@ -189,7 +201,6 @@ void free_proxy(struct proxy *p)
|
|||||||
struct switching_rule *rule, *ruleb;
|
struct switching_rule *rule, *ruleb;
|
||||||
struct redirect_rule *rdr, *rdrb;
|
struct redirect_rule *rdr, *rdrb;
|
||||||
struct logger *log, *logb;
|
struct logger *log, *logb;
|
||||||
struct logformat_node *lf, *lfb;
|
|
||||||
struct proxy_deinit_fct *pxdf;
|
struct proxy_deinit_fct *pxdf;
|
||||||
struct server_deinit_fct *srvdf;
|
struct server_deinit_fct *srvdf;
|
||||||
|
|
||||||
@ -252,12 +263,7 @@ void free_proxy(struct proxy *p)
|
|||||||
list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) {
|
list_for_each_entry_safe(srule, sruleb, &p->server_rules, list) {
|
||||||
LIST_DELETE(&srule->list);
|
LIST_DELETE(&srule->list);
|
||||||
free_acl_cond(srule->cond);
|
free_acl_cond(srule->cond);
|
||||||
list_for_each_entry_safe(lf, lfb, &srule->expr, list) {
|
free_logformat_list(&srule->expr);
|
||||||
LIST_DELETE(&lf->list);
|
|
||||||
release_sample_expr(lf->expr);
|
|
||||||
free(lf->arg);
|
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
free(srule->file);
|
free(srule->file);
|
||||||
free(srule);
|
free(srule);
|
||||||
}
|
}
|
||||||
@ -279,33 +285,10 @@ void free_proxy(struct proxy *p)
|
|||||||
free_logger(log);
|
free_logger(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry_safe(lf, lfb, &p->logformat, list) {
|
free_logformat_list(&p->logformat);
|
||||||
LIST_DELETE(&lf->list);
|
free_logformat_list(&p->logformat_sd);
|
||||||
release_sample_expr(lf->expr);
|
free_logformat_list(&p->format_unique_id);
|
||||||
free(lf->arg);
|
free_logformat_list(&p->logformat_error);
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
list_for_each_entry_safe(lf, lfb, &p->logformat_sd, list) {
|
|
||||||
LIST_DELETE(&lf->list);
|
|
||||||
release_sample_expr(lf->expr);
|
|
||||||
free(lf->arg);
|
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
list_for_each_entry_safe(lf, lfb, &p->format_unique_id, list) {
|
|
||||||
LIST_DELETE(&lf->list);
|
|
||||||
release_sample_expr(lf->expr);
|
|
||||||
free(lf->arg);
|
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
list_for_each_entry_safe(lf, lfb, &p->logformat_error, list) {
|
|
||||||
LIST_DELETE(&lf->list);
|
|
||||||
release_sample_expr(lf->expr);
|
|
||||||
free(lf->arg);
|
|
||||||
free(lf);
|
|
||||||
}
|
|
||||||
|
|
||||||
free_act_rules(&p->tcp_req.inspect_rules);
|
free_act_rules(&p->tcp_req.inspect_rules);
|
||||||
free_act_rules(&p->tcp_rep.inspect_rules);
|
free_act_rules(&p->tcp_rep.inspect_rules);
|
||||||
|
Loading…
Reference in New Issue
Block a user