1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

manager: let manager_free() handle NULLs

This makes the calling code a bit simpler.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2014-11-08 10:06:12 -05:00
parent f44b9efcec
commit 06d8d842e9
3 changed files with 6 additions and 7 deletions

View File

@ -1799,10 +1799,7 @@ int main(int argc, char *argv[]) {
finish: finish:
pager_close(); pager_close();
if (m) { m = manager_free(m);
manager_free(m);
m = NULL;
}
for (j = 0; j < ELEMENTSOF(arg_default_rlimit); j++) { for (j = 0; j < ELEMENTSOF(arg_default_rlimit); j++) {
free(arg_default_rlimit[j]); free(arg_default_rlimit[j]);

View File

@ -889,11 +889,12 @@ static void manager_clear_jobs_and_units(Manager *m) {
m->n_running_jobs = 0; m->n_running_jobs = 0;
} }
void manager_free(Manager *m) { Manager* manager_free(Manager *m) {
UnitType c; UnitType c;
int i; int i;
assert(m); if (!m)
return NULL;
manager_clear_jobs_and_units(m); manager_clear_jobs_and_units(m);
@ -955,6 +956,7 @@ void manager_free(Manager *m) {
hashmap_free(m->units_requiring_mounts_for); hashmap_free(m->units_requiring_mounts_for);
free(m); free(m);
return NULL;
} }
int manager_enumerate(Manager *m) { int manager_enumerate(Manager *m) {

View File

@ -296,7 +296,7 @@ struct Manager {
}; };
int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m); int manager_new(SystemdRunningAs running_as, bool test_run, Manager **m);
void manager_free(Manager *m); Manager* manager_free(Manager *m);
int manager_enumerate(Manager *m); int manager_enumerate(Manager *m);
int manager_startup(Manager *m, FILE *serialization, FDSet *fds); int manager_startup(Manager *m, FILE *serialization, FDSet *fds);