2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 18:07:57 +00:00

posix-timers: Helper for freeing proc parsed data

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2014-04-15 21:59:21 +04:00
parent b54e340945
commit d48d6c7267
3 changed files with 13 additions and 11 deletions

View File

@ -22,5 +22,6 @@ struct proc_posix_timers_stat {
};
extern int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat * args);
void free_posix_timers(struct proc_posix_timers_stat *st);
#endif /* __CR_PROC_POSIX_TIMER_H__ */

View File

@ -702,12 +702,7 @@ int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
}
end_posix:
while (!list_empty(&proc_args->timers)) {
temp = list_first_entry(&proc_args->timers, struct proc_posix_timer, list);
list_del(&temp->list);
xfree(temp);
}
free_posix_timers(proc_args);
return ret;
}

View File

@ -1337,6 +1337,16 @@ err:
return ret;
}
void free_posix_timers(struct proc_posix_timers_stat *st)
{
while (!list_empty(&st->timers)) {
struct proc_posix_timer *timer;
timer = list_first_entry(&st->timers, struct proc_posix_timer, list);
list_del(&timer->list);
xfree(timer);
}
}
int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
{
int ret = 0;
@ -1409,11 +1419,7 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
args->timer_n++;
}
err:
while (!list_empty(&args->timers)) {
timer = list_first_entry(&args->timers, struct proc_posix_timer, list);
list_del(&timer->list);
xfree(timer);
}
free_posix_timers(args);
pr_perror("Parse error in posix timers proc file!");
ret = -1;
out: