]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/main.c
pid1: rework environment block copy logic
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Nov 2019 10:26:05 +0000 (11:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Nov 2019 10:30:59 +0000 (11:30 +0100)
commit0e06a03165bdec49c79d12043e690d8f3a672812
tree023e6b804fc3d4ac9e1820b736bd937c9f7a2a1b
parent6878c02245b49987749e73a12003fcf07bf173ca
pid1: rework environment block copy logic

This reworks the logic introduced in
a5cede8c24fddda9b73f142e09b18b49adde1b9c (#13693).

First of all, let's move this out of util.c, since only PID 1 really
needs this, and there's no real need to have it in util.c.

Then, fix freeing of the variable. It previously relied on
STATIC_DESTRUCTOR_REGISTER() which however relies on static_destruct()
to be called explicitly. Currently only the main-func.h macros do that,
and PID 1 does not. (It might be worth investigating whether to do that,
but it's not trivial.) Hence the freeing wasn't applied.

Finally, an OOM check was missing, add it in.
src/basic/util.c
src/basic/util.h
src/core/main.c