diff options
author | Thomas Graf <tgraf@suug.ch> | 2010-11-26 15:32:10 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-11-26 15:32:10 (GMT) |
commit | 7105aea116208422812a3803ef1e58f08b45c75e (patch) | |
tree | 7db9c5c2874435a0cffea553aa2eca560b91feab | |
parent | c158d06b7b13dfcdc0fc66f8e8267a2493006926 (diff) | |
download | libnl-7105aea116208422812a3803ef1e58f08b45c75e.zip libnl-7105aea116208422812a3803ef1e58f08b45c75e.tar.gz libnl-7105aea116208422812a3803ef1e58f08b45c75e.tar.bz2 |
addr: hide nl_addr_destroy()
everyone should use nl_addr_put()
-rw-r--r-- | include/netlink/addr.h | 5 | ||||
-rw-r--r-- | lib/addr.c | 39 |
2 files changed, 15 insertions, 29 deletions
diff --git a/include/netlink/addr.h b/include/netlink/addr.h index cc3d201..794c4ff 100644 --- a/include/netlink/addr.h +++ b/include/netlink/addr.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch> */ #ifndef NETLINK_ADDR_H_ @@ -27,9 +27,6 @@ extern struct nl_addr * nl_addr_build(int, void *, size_t); extern int nl_addr_parse(const char *, int, struct nl_addr **); extern struct nl_addr * nl_addr_clone(struct nl_addr *); -/* Destroyage */ -extern void nl_addr_destroy(struct nl_addr *); - /* Usage Management */ extern struct nl_addr * nl_addr_get(struct nl_addr *); extern void nl_addr_put(struct nl_addr *); @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2003-2010 Thomas Graf <tgraf@suug.ch> */ /** @@ -151,6 +151,17 @@ static inline int dnet_pton(const char *src, char *addrbuf) return 1; } +static void addr_destroy(struct nl_addr *addr) +{ + if (!addr) + return; + + if (addr->a_refcnt != 1) + BUG(); + + free(addr); +} + /** * @name Creating Abstract Addresses * @{ @@ -395,7 +406,7 @@ prefix: char *p; long pl = strtol(++prefix, &p, 0); if (p == prefix) { - nl_addr_destroy(addr); + addr_destroy(addr); err = -NLE_INVAL; goto errout; } @@ -431,28 +442,6 @@ struct nl_addr *nl_addr_clone(struct nl_addr *addr) /** @} */ /** - * @name Destroying Abstract Addresses - * @{ - */ - -/** - * Destroy abstract address object. - * @arg addr Abstract address object. - */ -void nl_addr_destroy(struct nl_addr *addr) -{ - if (!addr) - return; - - if (addr->a_refcnt != 1) - BUG(); - - free(addr); -} - -/** @} */ - -/** * @name Managing Usage References * @{ */ @@ -470,7 +459,7 @@ void nl_addr_put(struct nl_addr *addr) return; if (addr->a_refcnt == 1) - nl_addr_destroy(addr); + addr_destroy(addr); else addr->a_refcnt--; } |