aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-07 14:34:56 +0200
committerSimon Ser <contact@emersion.fr>2023-07-07 17:31:11 +0200
commit7a9f8d8d6bf72fcea210552b7bec9b99f342f857 (patch)
treec84c622b9ea25646c081f81b534ec7c70b84ac84 /util
parent4966857f211cb6f48852928076a59f16aadb742b (diff)
Use struct initializers instead of memset()
This is a bit more type-safe.
Diffstat (limited to 'util')
-rw-r--r--util/addon.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/addon.c b/util/addon.c
index 75466691..0f9037a2 100644
--- a/util/addon.c
+++ b/util/addon.c
@@ -6,7 +6,7 @@
#include <wlr/util/log.h>
void wlr_addon_set_init(struct wlr_addon_set *set) {
- memset(set, 0, sizeof(*set));
+ *set = (struct wlr_addon_set){0};
wl_list_init(&set->addons);
}
@@ -26,7 +26,10 @@ void wlr_addon_set_finish(struct wlr_addon_set *set) {
void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set,
const void *owner, const struct wlr_addon_interface *impl) {
assert(impl);
- memset(addon, 0, sizeof(*addon));
+ *addon = (struct wlr_addon){
+ .impl = impl,
+ .owner = owner,
+ };
struct wlr_addon *iter;
wl_list_for_each(iter, &set->addons, link) {
if (iter->owner == addon->owner && iter->impl == addon->impl) {
@@ -34,8 +37,6 @@ void wlr_addon_init(struct wlr_addon *addon, struct wlr_addon_set *set,
}
}
wl_list_insert(&set->addons, &addon->link);
- addon->owner = owner;
- addon->impl = impl;
}
void wlr_addon_finish(struct wlr_addon *addon) {