window: Only unmap shm surface backing memory if it belongs to surface

Memory allocated out of the resize shm pool will be unmapped when the pool
is destroyed.
This commit is contained in:
Kristian Høgsberg
2012-04-10 11:32:35 -04:00
parent 6e2a8d74b5
commit 24b5e230fa
+5 -3
View File
@@ -464,6 +464,7 @@ shm_surface_data_destroy(void *p)
struct shm_surface_data *data = p; struct shm_surface_data *data = p;
wl_buffer_destroy(data->data.buffer); wl_buffer_destroy(data->data.buffer);
if (data->map)
munmap(data->map, data->length); munmap(data->map, data->length);
} }
@@ -523,9 +524,10 @@ display_create_shm_surface(struct display *display,
if (window && window->pool && data->length < window->pool_size) { if (window && window->pool && data->length < window->pool_size) {
pool = window->pool; pool = window->pool;
map = window->pool_data; map = window->pool_data;
data->map = NULL;
} else { } else {
pool = make_shm_pool(display, data->length, &data->map); pool = make_shm_pool(display, data->length, &map);
map = data->map; data->map = map;
} }
surface = cairo_image_surface_create_for_data (map, surface = cairo_image_surface_create_for_data (map,
@@ -547,7 +549,7 @@ display_create_shm_surface(struct display *display,
rectangle->height, rectangle->height,
stride, format); stride, format);
if (map == data->map) if (data->map)
wl_shm_pool_destroy(pool); wl_shm_pool_destroy(pool);
return surface; return surface;