addr: hide nl_addr_destroy()
everyone should use nl_addr_put()
This commit is contained in:
parent
c158d06b7b
commit
7105aea116
2 changed files with 15 additions and 29 deletions
|
@ -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 *);
|
||||
|
|
39
lib/addr.c
39
lib/addr.c
|
@ -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;
|
||||
}
|
||||
|
@ -430,28 +441,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--;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue