X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Funit.c;h=327444bba4d087f7b76b154506b498061111a4c5;hp=695044a77f33e9a5e54069bac3fdee518c6cf6a8;hb=c952c6ece28b6c0f774f823c917f458fe3424993;hpb=a013b84b49a7d4a30196949e24ea03066e227626 diff --git a/src/unit.c b/src/unit.c index 695044a77..327444bba 100644 --- a/src/unit.c +++ b/src/unit.c @@ -38,6 +38,7 @@ #include "unit-name.h" #include "specifier.h" #include "dbus-unit.h" +#include "special.h" const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = &service_vtable, @@ -323,10 +324,15 @@ void unit_free(Unit *u) { if (UNIT_VTABLE(u)->done) UNIT_VTABLE(u)->done(u); - /* Detach from next 'bigger' objects */ SET_FOREACH(t, u->meta.names, i) hashmap_remove_value(u->meta.manager->units, t, u); + if (u->meta.job) + job_free(u->meta.job); + + for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) + bidi_set_free(u, u->meta.dependencies[d]); + if (u->meta.type != _UNIT_TYPE_INVALID) LIST_REMOVE(Meta, units_per_type, u->meta.manager->units_per_type[u->meta.type], &u->meta); @@ -344,21 +350,12 @@ void unit_free(Unit *u) { u->meta.manager->n_in_gc_queue--; } - /* Free data and next 'smaller' objects */ - if (u->meta.job) - job_free(u->meta.job); - cgroup_bonding_free_list(u->meta.cgroup_bondings); - for (d = 0; d < _UNIT_DEPENDENCY_MAX; d++) - bidi_set_free(u, u->meta.dependencies[d]); - free(u->meta.description); free(u->meta.fragment_path); - while ((t = set_steal_first(u->meta.names))) - free(t); - set_free(u->meta.names); + set_free_free(u->meta.names); free(u->meta.instance); @@ -404,10 +401,7 @@ static void merge_names(Unit *u, Unit *other) { complete_move(&u->meta.names, &other->meta.names); - while ((t = set_steal_first(other->meta.names))) - free(t); - - set_free(other->meta.names); + set_free_free(other->meta.names); other->meta.names = NULL; other->meta.id = NULL;