phc2sys: Clean up before exiting.
Valgrind complains about memory leaks, none of which are serious. This patch frees the allocations on exit, so that any future *real* memory leaks will be obvious in the valgrind report. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
992e292055
commit
4e35931bc8
34
phc2sys.c
34
phc2sys.c
|
@ -262,11 +262,37 @@ static struct clock *clock_add(struct node *node, char *device)
|
||||||
|
|
||||||
static void clock_cleanup(struct node *node)
|
static void clock_cleanup(struct node *node)
|
||||||
{
|
{
|
||||||
struct clock *c;
|
struct clock *c, *tmp;
|
||||||
|
|
||||||
LIST_FOREACH(c, &node->clocks, list) {
|
LIST_FOREACH_SAFE(c, &node->clocks, list, tmp) {
|
||||||
if (c->device)
|
if (c->servo) {
|
||||||
|
servo_destroy(c->servo);
|
||||||
|
}
|
||||||
|
if (c->sanity_check) {
|
||||||
|
clockcheck_destroy(c->sanity_check);
|
||||||
|
}
|
||||||
|
if (c->delay_stats) {
|
||||||
|
stats_destroy(c->delay_stats);
|
||||||
|
}
|
||||||
|
if (c->freq_stats) {
|
||||||
|
stats_destroy(c->freq_stats);
|
||||||
|
}
|
||||||
|
if (c->offset_stats) {
|
||||||
|
stats_destroy(c->offset_stats);
|
||||||
|
}
|
||||||
|
if (c->device) {
|
||||||
free(c->device);
|
free(c->device);
|
||||||
|
}
|
||||||
|
free(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void port_cleanup(struct node *node)
|
||||||
|
{
|
||||||
|
struct port *p, *tmp;
|
||||||
|
|
||||||
|
LIST_FOREACH_SAFE(p, &node->ports, list, tmp) {
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,7 +1608,9 @@ end:
|
||||||
if (node.pmc)
|
if (node.pmc)
|
||||||
close_pmc(&node);
|
close_pmc(&node);
|
||||||
clock_cleanup(&node);
|
clock_cleanup(&node);
|
||||||
|
port_cleanup(&node);
|
||||||
config_destroy(cfg);
|
config_destroy(cfg);
|
||||||
|
msg_cleanup();
|
||||||
return r;
|
return r;
|
||||||
bad_usage:
|
bad_usage:
|
||||||
usage(progname);
|
usage(progname);
|
||||||
|
|
Loading…
Reference in New Issue