chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit: reduce heap usage for unit objects
[elogind.git]
/
src
/
unit.c
diff --git
a/src/unit.c
b/src/unit.c
index 1fbfb1dea5fb7df643f04ed5d46b1abe1c171c77..fa3c2649b35b87cba48d1cf117021f0f7602fc34 100644
(file)
--- a/
src/unit.c
+++ b/
src/unit.c
@@
-57,15
+57,18
@@
const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
[UNIT_PATH] = &path_vtable
};
[UNIT_PATH] = &path_vtable
};
-Unit *unit_new(Manager *m) {
+Unit *unit_new(Manager *m
, size_t size
) {
Unit *u;
assert(m);
Unit *u;
assert(m);
+ assert(size >= sizeof(Meta));
- if (!(u = new0(Unit, 1)))
+ u = malloc0(size);
+ if (!u)
return NULL;
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;
}
free(u);
return NULL;
}