From 1e2c7fce869c009fdcd91e011cffcfdf229816e7 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 12 Dec 2020 22:26:52 +0100 Subject: [PATCH] backend/drm: use wlr_drm_format_{create,add} Instead of manually allocating and initializing the structs, use the new wlr_drm_format helpers. --- backend/drm/renderer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 7599623a..61b838bc 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -256,20 +256,19 @@ bool drm_plane_init_surface(struct wlr_drm_plane *plane, return false; } } else { - const struct wlr_drm_format format_no_modifiers = { .format = format }; - drm_format = wlr_drm_format_dup(&format_no_modifiers); + drm_format = wlr_drm_format_create(format); } - struct wlr_drm_format *drm_format_linear = - calloc(1, sizeof(struct wlr_drm_format) + sizeof(uint64_t)); + struct wlr_drm_format *drm_format_linear = wlr_drm_format_create(format); if (drm_format_linear == NULL) { free(drm_format); return false; } - drm_format_linear->format = drm_format->format; - drm_format_linear->len = 1; - drm_format_linear->cap = 1; - drm_format_linear->modifiers[0] = DRM_FORMAT_MOD_LINEAR; + if (!wlr_drm_format_add(&drm_format_linear, DRM_FORMAT_MOD_LINEAR)) { + free(drm_format_linear); + free(drm_format); + return false; + } if (force_linear) { free(drm_format);