Use struct initializers instead of memset()

This is a bit more type-safe.
This commit is contained in:
Simon Ser 2023-07-07 14:34:56 +02:00
parent 4966857f21
commit 7a9f8d8d6b
34 changed files with 134 additions and 113 deletions

View file

@ -11,10 +11,11 @@ void wlr_buffer_init(struct wlr_buffer *buffer,
assert(impl->begin_data_ptr_access && impl->end_data_ptr_access);
}
memset(buffer, 0, sizeof(*buffer));
buffer->impl = impl;
buffer->width = width;
buffer->height = height;
*buffer = (struct wlr_buffer){
.impl = impl,
.width = width,
.height = height,
};
wl_signal_init(&buffer->events.destroy);
wl_signal_init(&buffer->events.release);
wlr_addon_set_init(&buffer->addons);

View file

@ -57,7 +57,7 @@ bool dmabuf_buffer_drop(struct wlr_dmabuf_buffer *buffer) {
if (!wlr_dmabuf_attributes_copy(&saved_dmabuf, &buffer->dmabuf)) {
wlr_log(WLR_ERROR, "Failed to save DMA-BUF");
ok = false;
memset(&buffer->dmabuf, 0, sizeof(buffer->dmabuf));
buffer->dmabuf = (struct wlr_dmabuf_attributes){0};
} else {
buffer->dmabuf = saved_dmabuf;
buffer->saved = true;