diff options
author | Thomas Haller <thaller@redhat.com> | 2022-04-22 16:10:21 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-04-22 16:10:21 (GMT) |
commit | 46506d3c1570f639726844fb689ab9b3d05b81e1 (patch) | |
tree | 778494eb877b636d466fbf955bf9ae24eaba819e | |
parent | 46e85d210282a626c0c19a9c6f2b8696342c1697 (diff) | |
download | libnl-46506d3c1570f639726844fb689ab9b3d05b81e1.zip libnl-46506d3c1570f639726844fb689ab9b3d05b81e1.tar.gz libnl-46506d3c1570f639726844fb689ab9b3d05b81e1.tar.bz2 |
route/mdb: add and use rtnl_mdb_entry_free() internal helper method
-rw-r--r-- | lib/route/mdb.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/route/mdb.c b/lib/route/mdb.c index 2bc27bb..4779ca3 100644 --- a/lib/route/mdb.c +++ b/lib/route/mdb.c @@ -14,6 +14,7 @@ #define MDB_ATTR_ENTRIES 0x000002 static struct rtnl_mdb_entry *rtnl_mdb_entry_alloc(void); +static void rtnl_mdb_entry_free(struct rtnl_mdb_entry *mdb_entry); static struct nl_cache_ops rtnl_mdb_ops; static struct nl_object_ops mdb_obj_ops; @@ -28,15 +29,13 @@ static void mdb_constructor(struct nl_object *obj) static void mdb_free_data(struct nl_object *obj) { - struct rtnl_mdb *mdb = (struct rtnl_mdb *) obj; + struct rtnl_mdb *mdb = (struct rtnl_mdb *)obj; struct rtnl_mdb_entry *mdb_entry; struct rtnl_mdb_entry *mdb_entry_safe; - nl_list_for_each_entry_safe(mdb_entry, mdb_entry_safe, &mdb->mdb_entry_list, mdb_list) { - nl_list_del(&mdb_entry->mdb_list); - nl_addr_put(mdb_entry->addr); - free(mdb_entry); - } + nl_list_for_each_entry_safe(mdb_entry, mdb_entry_safe, + &mdb->mdb_entry_list, mdb_list) + rtnl_mdb_entry_free(mdb_entry); } static int mdb_entry_equal(struct rtnl_mdb_entry *a, struct rtnl_mdb_entry *b) @@ -424,6 +423,13 @@ static struct rtnl_mdb_entry *rtnl_mdb_entry_alloc(void) } +static void rtnl_mdb_entry_free(struct rtnl_mdb_entry *mdb_entry) +{ + nl_list_del(&mdb_entry->mdb_list); + nl_addr_put(mdb_entry->addr); + free(mdb_entry); +} + static struct nl_af_group mdb_groups[] = { {AF_BRIDGE, RTNLGRP_MDB}, {END_OF_GROUP_LIST}, |