From 7c6212a0f71eeab23a4ff4241cb266ec219fad2d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 7 Aug 2020 19:02:49 +0200 Subject: render/drm_format_set: introduce wlr_drm_format_dup --- render/drm_format_set.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'render') diff --git a/render/drm_format_set.c b/render/drm_format_set.c index cbcc0875..54fc8ae1 100644 --- a/render/drm_format_set.c +++ b/render/drm_format_set.c @@ -6,6 +6,7 @@ #include #include #include +#include "render/drm_format_set.h" void wlr_drm_format_set_finish(struct wlr_drm_format_set *set) { for (size_t i = 0; i < set->len; ++i) { @@ -125,3 +126,14 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, set->formats[set->len++] = fmt; return true; } + +struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format) { + size_t format_size = sizeof(struct wlr_drm_format) + + format->len * sizeof(format->modifiers[0]); + struct wlr_drm_format *duped_format = malloc(format_size); + if (duped_format == NULL) { + return NULL; + } + memcpy(duped_format, format, format_size); + return duped_format; +} -- cgit v1.2.3