From d1e7922a587a239e16e0dbe654e63f76e1375e49 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 4 Jan 2013 20:27:11 +0100 Subject: libxtables: add xtables_rule_matches_free This function is shared by iptables and ip6tables. Signed-off-by: Pablo Neira Ayuso --- libxtables/xtables.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libxtables') diff --git a/libxtables/xtables.c b/libxtables/xtables.c index 4c912860..da174e20 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -1075,6 +1075,28 @@ void xtables_register_targets(struct xtables_target *target, unsigned int n) } while (n > 0); } +/* receives a list of xtables_rule_match, release them */ +void xtables_rule_matches_free(struct xtables_rule_match **matches) +{ + struct xtables_rule_match *matchp, *tmp; + + for (matchp = *matches; matchp;) { + tmp = matchp->next; + if (matchp->match->m) { + free(matchp->match->m); + matchp->match->m = NULL; + } + if (matchp->match == matchp->match->next) { + free(matchp->match); + matchp->match = NULL; + } + free(matchp); + matchp = tmp; + } + + *matches = NULL; +} + /** * xtables_param_act - act on condition * @status: a constant from enum xtables_exittype -- cgit v1.2.3