rc: use LIST_FOREACH_SAFE in cleanup()
according to the linux manpage, the "safe" variant may not be available on all platform. however we bundle our own `queue.h` so this should not be an issue.
This commit is contained in:
parent
0b4732520f
commit
3f82d5b1a3
@ -117,8 +117,7 @@ clean_failed(void)
|
|||||||
static void
|
static void
|
||||||
cleanup(void)
|
cleanup(void)
|
||||||
{
|
{
|
||||||
RC_PID *p1 = LIST_FIRST(&service_pids);
|
RC_PID *p, *tmp;
|
||||||
RC_PID *p2;
|
|
||||||
|
|
||||||
if (!rc_in_logger && !rc_in_plugin &&
|
if (!rc_in_logger && !rc_in_plugin &&
|
||||||
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
|
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
|
||||||
@ -140,16 +139,13 @@ cleanup(void)
|
|||||||
rc_logger_close();
|
rc_logger_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p1) {
|
LIST_FOREACH_SAFE(p, &service_pids, entries, tmp) {
|
||||||
p2 = LIST_NEXT(p1, entries);
|
LIST_REMOVE(p, entries);
|
||||||
free(p1);
|
free(p);
|
||||||
p1 = p2;
|
|
||||||
}
|
}
|
||||||
|
LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
|
||||||
for (p1 = LIST_FIRST(&free_these_pids); p1; /* no-op */) {
|
LIST_REMOVE(p, entries);
|
||||||
p2 = LIST_NEXT(p1, entries);
|
free(p);
|
||||||
free(p1);
|
|
||||||
p1 = p2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc_stringlist_free(main_hotplugged_services);
|
rc_stringlist_free(main_hotplugged_services);
|
||||||
|
Loading…
Reference in New Issue
Block a user