diff options
author | emersion <contact@emersion.fr> | 2018-05-25 19:42:23 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-27 14:09:48 +0100 |
commit | 36d5d4b40f5caf0b7bcccbcc3bfeec3afb23946b (patch) | |
tree | b0319dfd3cc0a4b221ddac5670f40b4476988b3b | |
parent | client/pool-buffer: set CLOEXEC on buffer FD, just in case (diff) | |
download | sway-36d5d4b40f5caf0b7bcccbcc3bfeec3afb23946b.tar.gz sway-36d5d4b40f5caf0b7bcccbcc3bfeec3afb23946b.tar.zst sway-36d5d4b40f5caf0b7bcccbcc3bfeec3afb23946b.zip |
client/pool-buffer: munmap in destroy_buffer
-rw-r--r-- | client/pool-buffer.c | 7 | ||||
-rw-r--r-- | include/pool-buffer.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/client/pool-buffer.c b/client/pool-buffer.c index 7610d223..52438303 100644 --- a/client/pool-buffer.c +++ b/client/pool-buffer.c | |||
@@ -72,7 +72,7 @@ static struct pool_buffer *create_buffer(struct wl_shm *shm, | |||
72 | struct pool_buffer *buf, int32_t width, int32_t height, | 72 | struct pool_buffer *buf, int32_t width, int32_t height, |
73 | uint32_t format) { | 73 | uint32_t format) { |
74 | uint32_t stride = width * 4; | 74 | uint32_t stride = width * 4; |
75 | uint32_t size = stride * height; | 75 | size_t size = stride * height; |
76 | 76 | ||
77 | char *name; | 77 | char *name; |
78 | int fd = create_pool_file(size, &name); | 78 | int fd = create_pool_file(size, &name); |
@@ -87,8 +87,10 @@ static struct pool_buffer *create_buffer(struct wl_shm *shm, | |||
87 | free(name); | 87 | free(name); |
88 | fd = -1; | 88 | fd = -1; |
89 | 89 | ||
90 | buf->size = size; | ||
90 | buf->width = width; | 91 | buf->width = width; |
91 | buf->height = height; | 92 | buf->height = height; |
93 | buf->data = data; | ||
92 | buf->surface = cairo_image_surface_create_for_data(data, | 94 | buf->surface = cairo_image_surface_create_for_data(data, |
93 | CAIRO_FORMAT_ARGB32, width, height, stride); | 95 | CAIRO_FORMAT_ARGB32, width, height, stride); |
94 | buf->cairo = cairo_create(buf->surface); | 96 | buf->cairo = cairo_create(buf->surface); |
@@ -111,6 +113,9 @@ void destroy_buffer(struct pool_buffer *buffer) { | |||
111 | if (buffer->pango) { | 113 | if (buffer->pango) { |
112 | g_object_unref(buffer->pango); | 114 | g_object_unref(buffer->pango); |
113 | } | 115 | } |
116 | if (buffer->data) { | ||
117 | munmap(buffer->data, buffer->size); | ||
118 | } | ||
114 | memset(buffer, 0, sizeof(struct pool_buffer)); | 119 | memset(buffer, 0, sizeof(struct pool_buffer)); |
115 | } | 120 | } |
116 | 121 | ||
diff --git a/include/pool-buffer.h b/include/pool-buffer.h index 856f7c8c..54f5be06 100644 --- a/include/pool-buffer.h +++ b/include/pool-buffer.h | |||
@@ -12,6 +12,8 @@ struct pool_buffer { | |||
12 | cairo_t *cairo; | 12 | cairo_t *cairo; |
13 | PangoContext *pango; | 13 | PangoContext *pango; |
14 | uint32_t width, height; | 14 | uint32_t width, height; |
15 | void *data; | ||
16 | size_t size; | ||
15 | bool busy; | 17 | bool busy; |
16 | }; | 18 | }; |
17 | 19 | ||