mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactoring: if_create() => if_init()
This commit is contained in:
parent
e2213b0b99
commit
fa2dc403aa
3 changed files with 9 additions and 7 deletions
|
@ -43,7 +43,7 @@ struct interface {
|
|||
* @retval >0 Success. A pointer to the new interface.
|
||||
* @retval 0 Error. The creation failed.
|
||||
*/
|
||||
struct interface * if_create(struct rtnl_link *link);
|
||||
int if_init(struct interface * , struct rtnl_link *link);
|
||||
|
||||
|
||||
/** Destroy interface by freeing dynamically allocated memory.
|
||||
|
|
|
@ -20,10 +20,8 @@
|
|||
|
||||
#include "utils.h"
|
||||
|
||||
struct interface * if_create(struct rtnl_link *link)
|
||||
int if_init(struct interface *i, struct rtnl_link *link)
|
||||
{
|
||||
struct interface *i = alloc(sizeof(struct interface));
|
||||
|
||||
i->nl_link = link;
|
||||
|
||||
debug(LOG_IF | 3, "Created interface '%s'", rtnl_link_get_name(i->nl_link));
|
||||
|
@ -36,7 +34,7 @@ struct interface * if_create(struct rtnl_link *link)
|
|||
|
||||
list_init(&i->sockets);
|
||||
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int if_destroy(struct interface *i)
|
||||
|
|
|
@ -64,8 +64,12 @@ int socket_init(int argc, char * argv[], config_setting_t *cfg)
|
|||
}
|
||||
|
||||
/* If not found, create a new interface */
|
||||
i = if_create(link);
|
||||
list_push(&interfaces, i);
|
||||
struct interface j;
|
||||
|
||||
if_init(&j, link);
|
||||
|
||||
list_push(&interfaces, memdup(&j, sizeof(j)));
|
||||
i = &j;
|
||||
|
||||
found: list_push(&i->sockets, s);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue