From: Tomasz Bursztyka Date: Thu, 22 Sep 2011 12:39:20 +0000 (+0300) Subject: tools: Added helper function to remove table entry in iptables-test X-Git-Tag: 2.0_alpha~1106 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8b43c537ad8efe6f0d8de62bc4114c328185f16;p=framework%2Fconnectivity%2Fconnman.git tools: Added helper function to remove table entry in iptables-test --- diff --git a/tools/iptables-test.c b/tools/iptables-test.c index 555aa2a..5e7c866 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; }