]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libxtables: define xtables_free_opts()
authorJamal Hadi Salim <hadi@cyberus.ca>
Wed, 11 Feb 2009 12:00:02 +0000 (13:00 +0100)
committerPatrick McHardy <kaber@trash.net>
Wed, 11 Feb 2009 12:00:02 +0000 (13:00 +0100)
Introduce xtables_free_opts() an xtables variant of
free_opts() which uses xtables_globals already set
by xtables_set_params(). The end goal is to have all internal
references in xtables.c use xtables_free_opts() instead of
depending on external defined free_opts()

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Patrick McHardy <kaber@trash.net>
include/xtables.h.in
xtables.c

index 61dbc767b39edb897eb6bad812064b1ce5670a73..1d333942b34c1756de42873ef79516f0853b9690 100644 (file)
@@ -204,6 +204,7 @@ extern void *xtables_malloc(size_t);
 extern int xtables_insmod(const char *, const char *, bool);
 extern int xtables_load_ko(const char *, bool);
 int xtables_set_params(struct xtables_globals *xtp);
+void xtables_free_opts(int reset_offset, struct option *original_opts);
 
 extern struct xtables_match *xtables_find_match(const char *name,
        enum xtables_tryload, struct xtables_rule_match **match);
index aad5e5338a0e246618417a127ae1862fdbf3676e..95be5f8eaac91c6ca9bb4c0c8affb09e2e099e66 100644 (file)
--- a/xtables.c
+++ b/xtables.c
@@ -68,6 +68,17 @@ int xtables_set_params(struct xtables_globals *xtp)
        return 0;
 }
 
+void xtables_free_opts(int reset_offset, struct option *original_opts)
+{
+       if (xt_params->opts != original_opts) {
+               if (original_opts) 
+                       free(xt_params->opts);
+               xt_params->opts = original_opts;
+               if (reset_offset)
+                       xt_params->option_offset = 0;
+       }
+}
+
 /**
  * xtables_afinfo - protocol family dependent information
  * @kmod:              kernel module basename (e.g. "ip_tables")