mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
proper release of path structure (path_destroy() vs free())
This commit is contained in:
parent
dab130545c
commit
e30e9292f2
4 changed files with 16 additions and 4 deletions
|
@ -91,4 +91,6 @@ void path_stats(struct path *p);
|
|||
|
||||
int path_print(struct path *p, char *buf, int len);
|
||||
|
||||
int path_destroy(struct path *p);
|
||||
|
||||
#endif /* _PATH_H_ */
|
||||
|
|
|
@ -147,11 +147,11 @@ int config_parse_path(config_setting_t *cfg,
|
|||
}
|
||||
}
|
||||
else {
|
||||
free(p);
|
||||
char buf[33];
|
||||
path_print(p, buf, sizeof(buf));
|
||||
|
||||
warn("Path %s is not enabled", buf);
|
||||
path_destroy(p);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -66,6 +66,7 @@ static void * path_send(void *arg)
|
|||
/** Receive messages */
|
||||
static void * path_run(void *arg)
|
||||
{
|
||||
char buf[33];
|
||||
struct path *p = arg;
|
||||
struct msg *m = alloc(sizeof(struct msg));
|
||||
if (!m)
|
||||
|
@ -205,3 +206,11 @@ int path_print(struct path *p, char *buf, int len)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int path_destroy(struct path *p)
|
||||
{
|
||||
list_destroy(&p->destinations);
|
||||
list_destroy(&p->hooks);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ static void quit()
|
|||
info("Stopping paths:");
|
||||
for (struct path *p = paths; p; p = p->next) { INDENT
|
||||
path_stop(p);
|
||||
path_destroy(p);
|
||||
}
|
||||
|
||||
info("Stopping nodes:");
|
||||
|
@ -50,7 +51,7 @@ static void quit()
|
|||
if_stop(i);
|
||||
}
|
||||
|
||||
/** @todo Free nodes and paths */
|
||||
/** @todo Free nodes */
|
||||
|
||||
config_destroy(&config);
|
||||
|
||||
|
@ -155,8 +156,8 @@ int main(int argc, char *argv[])
|
|||
struct path *p = paths;
|
||||
|
||||
info("Runtime Statistics:");
|
||||
info("%12s " MAG("=>") " %-12s: %-8s %-8s %-8s %-8s %-8s",
|
||||
"Source", "Destination", "#Sent", "#Recv", "#Drop", "#Skip", "#Inval");
|
||||
info("%-32s : %-8s %-8s %-8s %-8s %-8s",
|
||||
"Source " MAG("=>") " Destination", "#Sent", "#Recv", "#Drop", "#Skip", "#Inval");
|
||||
info("---------------------------------------------------------------------------");
|
||||
|
||||
while (1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue