REORG: global: move free acl/action in their related source files
Move deinit_acl_cond and deinit_act_rules from haproxy.c respectively in
acl.c and action.c. The name of the functions has been slightly altered,
replacing the prefix deinit_* by free_* to reflect their purpose more
clearly.
This change has been made in preparation to the implementation of a free
proxy function. As a side-effect, it helps to clean up haproxy.c.
diff --git a/include/haproxy/acl.h b/include/haproxy/acl.h
index cdbf9c0..bd6e1db 100644
--- a/include/haproxy/acl.h
+++ b/include/haproxy/acl.h
@@ -146,6 +146,7 @@
*/
int init_acl();
+void free_acl_cond(struct acl_cond *cond);
#endif /* _HAPROXY_ACL_H */
diff --git a/include/haproxy/action.h b/include/haproxy/action.h
index a4bec01..845c0fd 100644
--- a/include/haproxy/action.h
+++ b/include/haproxy/action.h
@@ -102,4 +102,6 @@
release_sample_expr(rule->arg.timeout.expr);
}
+void free_act_rules(struct list *rules);
+
#endif /* _HAPROXY_ACTION_H */
diff --git a/src/acl.c b/src/acl.c
index cf7dd91..7801e2e 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -1302,6 +1302,26 @@
return err;
}
+void free_acl_cond(struct acl_cond *cond)
+{
+ struct acl_term_suite *suite, *suiteb;
+ struct acl_term *term, *termb;
+
+ if (!cond)
+ return;
+
+ list_for_each_entry_safe(suite, suiteb, &cond->suites, list) {
+ list_for_each_entry_safe(term, termb, &suite->terms, list) {
+ LIST_DEL(&term->list);
+ free(term);
+ }
+ LIST_DEL(&suite->list);
+ free(suite);
+ }
+
+ free(cond);
+}
+
/************************************************************************/
/* All supported sample and ACL keywords must be declared here. */
/************************************************************************/
diff --git a/src/action.c b/src/action.c
index c817376..29eae81 100644
--- a/src/action.c
+++ b/src/action.c
@@ -10,6 +10,7 @@
*
*/
+#include <haproxy/acl.h>
#include <haproxy/action.h>
#include <haproxy/api.h>
#include <haproxy/errors.h>
@@ -259,3 +260,16 @@
return best_ptr;
}
+
+void free_act_rules(struct list *rules)
+{
+ struct act_rule *rule, *ruleb;
+
+ list_for_each_entry_safe(rule, ruleb, rules, list) {
+ LIST_DEL(&rule->list);
+ free_acl_cond(rule->cond);
+ if (rule->release_ptr)
+ rule->release_ptr(rule);
+ free(rule);
+ }
+}
diff --git a/src/haproxy.c b/src/haproxy.c
index 1d136e9..cf2f8e0 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -80,6 +80,7 @@
#include <import/sha1.h>
#include <haproxy/acl.h>
+#include <haproxy/action.h>
#include <haproxy/activity.h>
#include <haproxy/api.h>
#include <haproxy/arg.h>
@@ -2135,46 +2136,13 @@
free(err_msg);
}
-static void deinit_acl_cond(struct acl_cond *cond)
-{
- struct acl_term_suite *suite, *suiteb;
- struct acl_term *term, *termb;
-
- if (!cond)
- return;
-
- list_for_each_entry_safe(suite, suiteb, &cond->suites, list) {
- list_for_each_entry_safe(term, termb, &suite->terms, list) {
- LIST_DEL(&term->list);
- free(term);
- }
- LIST_DEL(&suite->list);
- free(suite);
- }
-
- free(cond);
-}
-
-static void deinit_act_rules(struct list *rules)
-{
- struct act_rule *rule, *ruleb;
-
- list_for_each_entry_safe(rule, ruleb, rules, list) {
- LIST_DEL(&rule->list);
- deinit_acl_cond(rule->cond);
- if (rule->release_ptr)
- rule->release_ptr(rule);
- free(rule);
- }
-}
-
static void deinit_stick_rules(struct list *rules)
{
struct sticking_rule *rule, *ruleb;
list_for_each_entry_safe(rule, ruleb, rules, list) {
LIST_DEL(&rule->list);
- deinit_acl_cond(rule->cond);
+ free_acl_cond(rule->cond);
release_sample_expr(rule->expr);
free(rule);
}
@@ -2367,13 +2335,13 @@
free(lf);
}
- deinit_act_rules(&p->tcp_req.inspect_rules);
- deinit_act_rules(&p->tcp_rep.inspect_rules);
- deinit_act_rules(&p->tcp_req.l4_rules);
- deinit_act_rules(&p->tcp_req.l5_rules);
- deinit_act_rules(&p->http_req_rules);
- deinit_act_rules(&p->http_res_rules);
- deinit_act_rules(&p->http_after_res_rules);
+ free_act_rules(&p->tcp_req.inspect_rules);
+ free_act_rules(&p->tcp_rep.inspect_rules);
+ free_act_rules(&p->tcp_req.l4_rules);
+ free_act_rules(&p->tcp_req.l5_rules);
+ free_act_rules(&p->http_req_rules);
+ free_act_rules(&p->http_res_rules);
+ free_act_rules(&p->http_after_res_rules);
deinit_stick_rules(&p->storersp_rules);
deinit_stick_rules(&p->sticking_rules);
@@ -2461,7 +2429,7 @@
free(uap->desc);
userlist_free(uap->userlist);
- deinit_act_rules(&uap->http_req_rules);
+ free_act_rules(&uap->http_req_rules);
scope = uap->scope;
while (scope) {