1
0
Fork 0
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:
Steffen Vogel 2017-03-12 17:08:04 -03:00
parent e2213b0b99
commit fa2dc403aa
3 changed files with 9 additions and 7 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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);
}