diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2011-09-22 15:39:20 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-09-22 15:22:46 +0200 |
commit | c8b43c537ad8efe6f0d8de62bc4114c328185f16 (patch) | |
tree | f1191da96ea542099d0f91a77086b4a90140559c /tools | |
parent | 006cef4c716726eae7091f62565712dd2c5d4df5 (diff) | |
download | connman-c8b43c537ad8efe6f0d8de62bc4114c328185f16.tar.gz connman-c8b43c537ad8efe6f0d8de62bc4114c328185f16.tar.bz2 connman-c8b43c537ad8efe6f0d8de62bc4114c328185f16.zip |
tools: Added helper function to remove table entry in iptables-test
Diffstat (limited to 'tools')
-rw-r--r-- | tools/iptables-test.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/iptables-test.c b/tools/iptables-test.c index 555aa2a2..5e7c8668 100644 --- a/tools/iptables-test.c +++ b/tools/iptables-test.c @@ -327,6 +327,22 @@ static int connman_add_entry(struct connman_iptables *table, return 0; } +static int remove_table_entry(struct connman_iptables *table, + struct connman_iptables_entry *entry) +{ + int removed = 0; + + table->num_entries--; + table->size -= entry->entry->next_offset; + removed = entry->entry->next_offset; + + g_free(entry->entry); + + table->entries = g_list_remove(table->entries, entry); + + return removed; +} + static int connman_iptables_flush_chain(struct connman_iptables *table, char *name) { @@ -357,11 +373,7 @@ static int connman_iptables_flush_chain(struct connman_iptables *table, entry = list->data; next = g_list_next(list); - table->num_entries--; - table->size -= entry->entry->next_offset; - removed += entry->entry->next_offset; - - table->entries = g_list_remove(table->entries, list->data); + removed += remove_table_entry(table, entry); list = next; } |