From 58d4cfaca3a0934109fd4a2651b8ae3af758ca2c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 1 Oct 2022 17:55:49 +0200 Subject: render/allocator/drm_dumb: drop finish_buffer() Simplify things a bit. --- render/allocator/drm_dumb.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'render') diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c index 03d9ff98..fab3e930 100644 --- a/render/allocator/drm_dumb.c +++ b/render/allocator/drm_dumb.c @@ -28,23 +28,6 @@ static struct wlr_drm_dumb_buffer *drm_dumb_buffer_from_buffer( return (struct wlr_drm_dumb_buffer *)wlr_buf; } -static void finish_buffer(struct wlr_drm_dumb_buffer *buf) { - if (buf->data) { - munmap(buf->data, buf->size); - } - - wlr_dmabuf_attributes_finish(&buf->dmabuf); - - if (buf->drm_fd >= 0) { - struct drm_mode_destroy_dumb destroy = { .handle = buf->handle }; - if (drmIoctl(buf->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy)) { - wlr_log_errno(WLR_ERROR, "Failed to destroy DRM dumb buffer"); - } - } - - wl_list_remove(&buf->link); -} - static struct wlr_drm_dumb_buffer *create_buffer( struct wlr_drm_dumb_allocator *alloc, int width, int height, const struct wlr_drm_format *format) { @@ -132,8 +115,7 @@ static struct wlr_drm_dumb_buffer *create_buffer( return buffer; create_destroy: - finish_buffer(buffer); - free(buffer); + wlr_buffer_drop(&buffer->base); return NULL; } @@ -159,7 +141,21 @@ static bool buffer_get_dmabuf(struct wlr_buffer *wlr_buffer, static void buffer_destroy(struct wlr_buffer *wlr_buffer) { struct wlr_drm_dumb_buffer *buf = drm_dumb_buffer_from_buffer(wlr_buffer); - finish_buffer(buf); + + if (buf->data) { + munmap(buf->data, buf->size); + } + + wlr_dmabuf_attributes_finish(&buf->dmabuf); + + if (buf->drm_fd >= 0) { + struct drm_mode_destroy_dumb destroy = { .handle = buf->handle }; + if (drmIoctl(buf->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy)) { + wlr_log_errno(WLR_ERROR, "Failed to destroy DRM dumb buffer"); + } + } + + wl_list_remove(&buf->link); free(buf); } -- cgit v1.2.3