From 099a147439b5b20d466316ae3dc8215f30ff3c1c Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 4 May 2023 18:26:45 -0400 Subject: wlr_drm_format: Change wlr_drm_format_create to init --- include/render/drm_format_set.h | 2 +- render/drm_format_set.c | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/render/drm_format_set.h b/include/render/drm_format_set.h index 8614d0b9..8734ea7a 100644 --- a/include/render/drm_format_set.h +++ b/include/render/drm_format_set.h @@ -3,7 +3,7 @@ #include -struct wlr_drm_format *wlr_drm_format_create(uint32_t format); +void wlr_drm_format_init(struct wlr_drm_format *fmt, uint32_t format); bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier); bool wlr_drm_format_add(struct wlr_drm_format *fmt, uint64_t modifier); struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format); diff --git a/render/drm_format_set.c b/render/drm_format_set.c index 2412144c..52603db7 100644 --- a/render/drm_format_set.c +++ b/render/drm_format_set.c @@ -64,10 +64,12 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, return wlr_drm_format_add(*ptr, modifier); } - struct wlr_drm_format *fmt = wlr_drm_format_create(format); + struct wlr_drm_format *fmt = calloc(1, sizeof(*fmt)); if (!fmt) { return false; } + + wlr_drm_format_init(fmt, format); if (!wlr_drm_format_add(fmt, modifier)) { wlr_drm_format_finish(fmt); return false; @@ -92,17 +94,9 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, return true; } -struct wlr_drm_format *wlr_drm_format_create(uint32_t format) { - size_t capacity = 4; - struct wlr_drm_format *fmt = calloc(1, sizeof(*fmt)); - if (!fmt) { - wlr_log_errno(WLR_ERROR, "Allocation failed"); - return NULL; - } +void wlr_drm_format_init(struct wlr_drm_format *fmt, uint32_t format) { + memset(fmt, 0, sizeof(*fmt)); fmt->format = format; - fmt->capacity = capacity; - fmt->modifiers = malloc(sizeof(*fmt->modifiers) * capacity); - return fmt; } bool wlr_drm_format_has(const struct wlr_drm_format *fmt, uint64_t modifier) { -- cgit v1.2.3