render/allocator/drm_dumb: drop finish_buffer()

Simplify things a bit.
Simon Ser 2 years ago committed by Alexander Orzechowski
parent c659792d7b
commit 58d4cfaca3

@ -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);
}

Loading…
Cancel
Save