chiark / gitweb /
unit: reduce heap usage for unit objects
[elogind.git] / src / unit.c
index 3b476a8e02ec3da205e95c129f74f1e7e57b03da..fa3c2649b35b87cba48d1cf117021f0f7602fc34 100644 (file)
@@ -57,15 +57,18 @@ const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
         [UNIT_PATH] = &path_vtable
 };
 
-Unit *unit_new(Manager *m) {
+Unit *unit_new(Manager *m, size_t size) {
         Unit *u;
 
         assert(m);
+        assert(size >= sizeof(Meta));
 
-        if (!(u = new0(Unit, 1)))
+        u = malloc0(size);
+        if (!u)
                 return NULL;
 
-        if (!(u->meta.names = set_new(string_hash_func, string_compare_func))) {
+        u->meta.names = set_new(string_hash_func, string_compare_func);
+        if (!u->meta.names) {
                 free(u);
                 return NULL;
         }
@@ -1338,7 +1341,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
                 }
         }
 
-        manager_recheck_syslog(u->meta.manager);
+        manager_recheck_journal(u->meta.manager);
 
         /* Maybe we finished startup and are now ready for being
          * stopped because unneeded? */
@@ -1539,7 +1542,9 @@ int unit_add_dependency(Unit *u, UnitDependency d, Unit *other, bool add_referen
                 [UNIT_REFERENCES] = UNIT_REFERENCED_BY,
                 [UNIT_REFERENCED_BY] = UNIT_REFERENCES,
                 [UNIT_TRIGGERS] = UNIT_TRIGGERED_BY,
-                [UNIT_TRIGGERED_BY] = UNIT_TRIGGERS
+                [UNIT_TRIGGERED_BY] = UNIT_TRIGGERS,
+                [UNIT_PROPAGATE_RELOAD_TO] = UNIT_PROPAGATE_RELOAD_FROM,
+                [UNIT_PROPAGATE_RELOAD_FROM] = UNIT_PROPAGATE_RELOAD_TO
         };
         int r, q = 0, v = 0, w = 0;
 
@@ -2663,7 +2668,9 @@ static const char* const unit_dependency_table[_UNIT_DEPENDENCY_MAX] = {
         [UNIT_REFERENCED_BY] = "ReferencedBy",
         [UNIT_ON_FAILURE] = "OnFailure",
         [UNIT_TRIGGERS] = "Triggers",
-        [UNIT_TRIGGERED_BY] = "TriggeredBy"
+        [UNIT_TRIGGERED_BY] = "TriggeredBy",
+        [UNIT_PROPAGATE_RELOAD_TO] = "PropagateReloadTo",
+        [UNIT_PROPAGATE_RELOAD_FROM] = "PropagateReloadFrom"
 };
 
 DEFINE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);