diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.c | 28 | ||||
-rw-r--r-- | src/expr.c | 2 | ||||
-rw-r--r-- | src/expr/data_reg.c | 2 | ||||
-rw-r--r-- | src/expr/immediate.c | 2 | ||||
-rw-r--r-- | src/expr/log.c | 4 | ||||
-rw-r--r-- | src/expr/match.c | 4 | ||||
-rw-r--r-- | src/expr/target.c | 4 | ||||
-rw-r--r-- | src/internal.h | 2 | ||||
-rw-r--r-- | src/mxml.c | 12 | ||||
-rw-r--r-- | src/rule.c | 26 | ||||
-rw-r--r-- | src/set.c | 22 | ||||
-rw-r--r-- | src/set_elem.c | 10 | ||||
-rw-r--r-- | src/table.c | 18 | ||||
-rw-r--r-- | src/utils.c | 5 |
14 files changed, 74 insertions, 67 deletions
diff --git a/src/chain.c b/src/chain.c index 69ea68f..1f1760a 100644 --- a/src/chain.c +++ b/src/chain.c @@ -61,11 +61,11 @@ EXPORT_SYMBOL(nft_chain_alloc); void nft_chain_free(struct nft_chain *c) { if (c->table != NULL) - free(c->table); + xfree(c->table); if (c->type != NULL) - free(c->type); + xfree(c->type); - free(c); + xfree(c); } EXPORT_SYMBOL(nft_chain_free); @@ -83,7 +83,7 @@ void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr) switch (attr) { case NFT_CHAIN_ATTR_TABLE: if (c->table) { - free(c->table); + xfree(c->table); c->table = NULL; } break; @@ -92,7 +92,7 @@ void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr) return; case NFT_CHAIN_ATTR_TYPE: if (c->type) { - free(c->type); + xfree(c->type); c->type = NULL; } break; @@ -121,7 +121,7 @@ void nft_chain_attr_set(struct nft_chain *c, uint16_t attr, const void *data) break; case NFT_CHAIN_ATTR_TABLE: if (c->table) - free(c->table); + xfree(c->table); c->table = strdup(data); break; @@ -151,7 +151,7 @@ void nft_chain_attr_set(struct nft_chain *c, uint16_t attr, const void *data) break; case NFT_CHAIN_ATTR_TYPE: if (c->type) - free(c->type); + xfree(c->type); c->type = strdup(data); break; @@ -570,11 +570,11 @@ static int nft_chain_json_parse(struct nft_chain *c, char *json) nft_chain_attr_set_u32(c, NFT_CHAIN_ATTR_POLICY, policy); } - free(root); + xfree(root); return 0; err: - free(root); + xfree(root); return -1; #else errno = EOPNOTSUPP; @@ -658,7 +658,7 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) } if (c->type) - free(c->type); + xfree(c->type); c->type = strdup(node->child->value.opaque); c->flags |= (1 << NFT_CHAIN_ATTR_TYPE); @@ -670,7 +670,7 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) return -1; } if (c->table) - free(c->table); + xfree(c->table); c->table = strdup(node->child->value.opaque); c->flags |= (1 << NFT_CHAIN_ATTR_TABLE); @@ -695,7 +695,7 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) } hooknum = nft_str2hooknum(hooknum_str); - free((char *)hooknum_str); + xfree(hooknum_str); if (hooknum < 0) { mxmlDelete(tree); @@ -903,7 +903,7 @@ void nft_chain_list_free(struct nft_chain_list *list) list_del(&r->head); nft_chain_free(r); } - free(list); + xfree(list); } EXPORT_SYMBOL(nft_chain_list_free); @@ -982,6 +982,6 @@ EXPORT_SYMBOL(nft_chain_list_iter_next); void nft_chain_list_iter_destroy(struct nft_chain_list_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_chain_list_iter_destroy); @@ -49,7 +49,7 @@ EXPORT_SYMBOL(nft_rule_expr_alloc); void nft_rule_expr_free(struct nft_rule_expr *expr) { - free(expr); + xfree(expr); } EXPORT_SYMBOL(nft_rule_expr_free); diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c index 85c441e..305e4d2 100644 --- a/src/expr/data_reg.c +++ b/src/expr/data_reg.c @@ -106,7 +106,7 @@ static int nft_data_reg_chain_xml_parse(union nft_data_reg *reg, char *xml) /* Get and set <chain> */ if (reg->chain) - free(reg->chain); + xfree(reg->chain); reg->chain = (char *)nft_mxml_str_parse(tree, "chain", MXML_DESCEND); diff --git a/src/expr/immediate.c b/src/expr/immediate.c index e65bd7c..2061172 100644 --- a/src/expr/immediate.c +++ b/src/expr/immediate.c @@ -46,7 +46,7 @@ nft_rule_expr_immediate_set(struct nft_rule_expr *e, uint16_t type, break; case NFT_EXPR_IMM_CHAIN: if (imm->data.chain) - free(imm->data.chain); + xfree(imm->data.chain); imm->data.chain = strdup(data); break; diff --git a/src/expr/log.c b/src/expr/log.c index be2b40e..5b9b871 100644 --- a/src/expr/log.c +++ b/src/expr/log.c @@ -38,7 +38,7 @@ nft_rule_expr_log_set(struct nft_rule_expr *e, uint16_t type, switch(type) { case NFT_EXPR_LOG_PREFIX: if (log->prefix) - free(log->prefix); + xfree(log->prefix); log->prefix = strdup(data); break; @@ -131,7 +131,7 @@ nft_rule_expr_log_parse(struct nft_rule_expr *e, struct nlattr *attr) if (tb[NFTA_LOG_PREFIX]) { if (log->prefix) - free(log->prefix); + xfree(log->prefix); log->prefix = strdup(mnl_attr_get_str(tb[NFTA_LOG_PREFIX])); e->flags |= (1 << NFT_EXPR_LOG_GROUP); diff --git a/src/expr/match.c b/src/expr/match.c index 9eb31c5..d155bb3 100644 --- a/src/expr/match.c +++ b/src/expr/match.c @@ -50,7 +50,7 @@ nft_rule_expr_match_set(struct nft_rule_expr *e, uint16_t type, break; case NFT_EXPR_MT_INFO: if (mt->data) - free((void *)mt->data); + xfree(mt->data); mt->data = data; mt->data_len = data_len; @@ -153,7 +153,7 @@ static int nft_rule_expr_match_parse(struct nft_rule_expr *e, struct nlattr *att void *match_data; if (match->data) - free((void *) match->data); + xfree(match->data); match_data = calloc(1, len); if (match_data == NULL) diff --git a/src/expr/target.c b/src/expr/target.c index e59f86a..5ef53cb 100644 --- a/src/expr/target.c +++ b/src/expr/target.c @@ -50,7 +50,7 @@ nft_rule_expr_target_set(struct nft_rule_expr *e, uint16_t type, break; case NFT_EXPR_TG_INFO: if (tg->data) - free((void *)tg->data); + xfree(tg->data); tg->data = data; tg->data_len = data_len; @@ -153,7 +153,7 @@ static int nft_rule_expr_target_parse(struct nft_rule_expr *e, struct nlattr *at void *target_data; if (target->data) - free((void *) target->data); + xfree(target->data); target_data = calloc(1, len); if (target_data == NULL) diff --git a/src/internal.h b/src/internal.h index d1c7690..4d39660 100644 --- a/src/internal.h +++ b/src/internal.h @@ -55,6 +55,8 @@ const char *nft_verdict2str(uint32_t verdict); int nft_str2verdict(const char *verdict); int nft_get_value(enum nft_type type, void *val, void *out); +void xfree(const void *ptr); + struct expr_ops; struct nft_rule_expr { @@ -41,7 +41,7 @@ struct nft_rule_expr *nft_mxml_expr_parse(mxml_node_t *node) goto err_expr; tree = mxmlLoadString(NULL, xml_text, MXML_OPAQUE_CALLBACK); - free(xml_text); + xfree(xml_text); if (tree == NULL) goto err_expr; @@ -104,7 +104,7 @@ int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, } ret = nft_data_reg_xml_parse(data_reg, tmpstr); - free(tmpstr); + xfree(tmpstr); if (ret < 0) { errno = EINVAL; @@ -190,18 +190,18 @@ struct nft_set_elem *nft_mxml_set_elem_parse(mxml_node_t *node) node->next = save; if (set_elem_str == NULL) { - free(elem); + xfree(elem); goto enomem; } if (nft_set_elem_parse(elem, NFT_SET_PARSE_XML, set_elem_str) != 0) { - free(set_elem_str); - free(elem); + xfree(set_elem_str); + xfree(elem); return NULL; } - free(set_elem_str); + xfree(set_elem_str); return elem; einval: @@ -65,11 +65,11 @@ EXPORT_SYMBOL(nft_rule_alloc); void nft_rule_free(struct nft_rule *r) { if (r->table != NULL) - free(r->table); + xfree(r->table); if (r->chain != NULL) - free(r->chain); + xfree(r->chain); - free(r); + xfree(r); } EXPORT_SYMBOL(nft_rule_free); @@ -87,13 +87,13 @@ void nft_rule_attr_unset(struct nft_rule *r, uint16_t attr) switch (attr) { case NFT_RULE_ATTR_TABLE: if (r->table) { - free(r->table); + xfree(r->table); r->table = NULL; } break; case NFT_RULE_ATTR_CHAIN: if (r->chain) { - free(r->chain); + xfree(r->chain); r->chain = NULL; } break; @@ -115,13 +115,13 @@ void nft_rule_attr_set(struct nft_rule *r, uint16_t attr, const void *data) switch(attr) { case NFT_RULE_ATTR_TABLE: if (r->table) - free(r->table); + xfree(r->table); r->table = strdup(data); break; case NFT_RULE_ATTR_CHAIN: if (r->chain) - free(r->chain); + xfree(r->chain); r->chain = strdup(data); break; @@ -371,7 +371,7 @@ static int nft_rule_parse_expr2(struct nlattr *attr, struct nft_rule *r) if (tb[NFTA_EXPR_DATA]) { if (expr->ops->parse(expr, tb[NFTA_EXPR_DATA]) < 0) { - free(expr); + xfree(expr); return -1; } } @@ -508,7 +508,7 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) } if (r->table) - free(r->table); + xfree(r->table); r->table = strdup(mxmlElementGetAttr(tree, "table")); r->flags |= (1 << NFT_RULE_ATTR_TABLE); @@ -520,7 +520,7 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) } if (r->chain) - free(r->chain); + xfree(r->chain); r->chain = strdup(mxmlElementGetAttr(tree, "chain")); r->flags |= (1 << NFT_RULE_ATTR_CHAIN); @@ -806,7 +806,7 @@ EXPORT_SYMBOL(nft_rule_expr_iter_next); void nft_rule_expr_iter_destroy(struct nft_rule_expr_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_rule_expr_iter_destroy); @@ -836,7 +836,7 @@ void nft_rule_list_free(struct nft_rule_list *list) list_del(&r->head); nft_rule_free(r); } - free(list); + xfree(list); } EXPORT_SYMBOL(nft_rule_list_free); @@ -915,6 +915,6 @@ EXPORT_SYMBOL(nft_rule_list_iter_next); void nft_rule_list_iter_destroy(struct nft_rule_list_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_rule_list_iter_destroy); @@ -46,15 +46,15 @@ void nft_set_free(struct nft_set *s) struct nft_set_elem *elem, *tmp; if (s->table != NULL) - free(s->table); + xfree(s->table); if (s->name != NULL) - free(s->name); + xfree(s->name); list_for_each_entry_safe(elem, tmp, &s->element_list, head) { list_del(&elem->head); nft_set_elem_free(elem); } - free(s); + xfree(s); } EXPORT_SYMBOL(nft_set_free); @@ -70,14 +70,14 @@ void nft_set_attr_unset(struct nft_set *s, uint16_t attr) case NFT_SET_ATTR_TABLE: if (s->flags & (1 << NFT_SET_ATTR_TABLE)) if (s->table) { - free(s->table); + xfree(s->table); s->table = NULL; } break; case NFT_SET_ATTR_NAME: if (s->flags & (1 << NFT_SET_ATTR_NAME)) if (s->name) { - free(s->name); + xfree(s->name); s->name = NULL; } break; @@ -101,13 +101,13 @@ void nft_set_attr_set(struct nft_set *s, uint16_t attr, const void *data) switch(attr) { case NFT_SET_ATTR_TABLE: if (s->table) - free(s->table); + xfree(s->table); s->table = strdup(data); break; case NFT_SET_ATTR_NAME: if (s->name) - free(s->name); + xfree(s->name); s->name = strdup(data); break; @@ -329,7 +329,7 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) goto err; if (s->name) - free(s->name); + xfree(s->name); s->name = name; s->flags |= (1 << NFT_SET_ATTR_NAME); @@ -340,7 +340,7 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) goto err; if (s->table) - free(s->table); + xfree(s->table); s->table = strdup(table); s->flags |= (1 << NFT_SET_ATTR_TABLE); @@ -594,7 +594,7 @@ void nft_set_list_free(struct nft_set_list *list) list_del(&s->head); nft_set_free(s); } - free(list); + xfree(list); } EXPORT_SYMBOL(nft_set_list_free); @@ -672,6 +672,6 @@ EXPORT_SYMBOL(nft_set_list_iter_next); void nft_set_list_iter_destroy(struct nft_set_list_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_set_list_iter_destroy); diff --git a/src/set_elem.c b/src/set_elem.c index 5325373..4e21719 100644 --- a/src/set_elem.c +++ b/src/set_elem.c @@ -42,7 +42,7 @@ EXPORT_SYMBOL(nft_set_elem_alloc); void nft_set_elem_free(struct nft_set_elem *s) { - free(s); + xfree(s); } EXPORT_SYMBOL(nft_set_elem_free); @@ -58,7 +58,7 @@ void nft_set_elem_attr_unset(struct nft_set_elem *s, uint16_t attr) case NFT_SET_ELEM_ATTR_CHAIN: if (s->flags & (1 << NFT_SET_ELEM_ATTR_CHAIN)) { if (s->data.chain) { - free(s->data.chain); + xfree(s->data.chain); s->data.chain = NULL; } } @@ -92,7 +92,7 @@ void nft_set_elem_attr_set(struct nft_set_elem *s, uint16_t attr, break; case NFT_SET_ELEM_ATTR_CHAIN: /* NFTA_SET_ELEM_DATA */ if (s->data.chain) - free(s->data.chain); + xfree(s->data.chain); s->data.chain = strdup(data); break; @@ -299,7 +299,7 @@ static int nft_set_elems_parse2(struct nft_set *s, const struct nlattr *nest) } } if (ret < 0) - free(e); + xfree(e); /* Add this new element to this set */ list_add_tail(&e->head, &s->element_list); @@ -656,6 +656,6 @@ EXPORT_SYMBOL(nft_set_elems_iter_next); void nft_set_elems_iter_destroy(struct nft_set_elems_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_set_elems_iter_destroy); diff --git a/src/table.c b/src/table.c index 76a1b4b..92ad37d 100644 --- a/src/table.c +++ b/src/table.c @@ -43,9 +43,9 @@ EXPORT_SYMBOL(nft_table_alloc); void nft_table_free(struct nft_table *t) { if (t->flags & (1 << NFT_TABLE_ATTR_NAME)) - free(t->name); + xfree(t->name); - free(t); + xfree(t); } EXPORT_SYMBOL(nft_table_free); @@ -63,7 +63,7 @@ void nft_table_attr_unset(struct nft_table *t, uint16_t attr) switch (attr) { case NFT_TABLE_ATTR_NAME: if (t->name) { - free(t->name); + xfree(t->name); t->name = NULL; } break; @@ -80,7 +80,7 @@ void nft_table_attr_set(struct nft_table *t, uint16_t attr, const void *data) switch (attr) { case NFT_TABLE_ATTR_NAME: if (t->name) - free(t->name); + xfree(t->name); t->name = strdup(data); t->flags |= (1 << NFT_TABLE_ATTR_NAME); @@ -239,7 +239,7 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml) } if (t->name) - free(t->name); + xfree(t->name); t->name = strdup(mxmlElementGetAttr(tree, "name")); t->flags |= (1 << NFT_TABLE_ATTR_NAME); @@ -313,10 +313,10 @@ static int nft_table_json_parse(struct nft_table *t, char *json) nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, table_flag); - free(root); + xfree(root); return 0; err: - free(root); + xfree(root); return -1; #else errno = EOPNOTSUPP; @@ -414,7 +414,7 @@ void nft_table_list_free(struct nft_table_list *list) list_del(&r->head); nft_table_free(r); } - free(list); + xfree(list); } EXPORT_SYMBOL(nft_table_list_free); @@ -487,6 +487,6 @@ EXPORT_SYMBOL(nft_table_list_iter_next); void nft_table_list_iter_destroy(struct nft_table_list_iter *iter) { - free(iter); + xfree(iter); } EXPORT_SYMBOL(nft_table_list_iter_destroy); diff --git a/src/utils.c b/src/utils.c index c6bf9ff..848eba9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -168,3 +168,8 @@ int nft_str2verdict(const char *verdict) return -1; } + +void xfree(const void *ptr) +{ + free((void *)ptr); +} |