From: Ander Conselvan de Oliveira Date: Wed, 23 May 2012 13:09:55 +0000 (+0300) Subject: shm: use mremap on pool resize X-Git-Tag: 0.94.90~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=086b4e2c1a129b55986a67ec0d8be35b29707a95;p=profile%2Fivi%2Fwayland.git shm: use mremap on pool resize --- diff --git a/src/wayland-shm.c b/src/wayland-shm.c index e071392..62afc3b 100644 --- a/src/wayland-shm.c +++ b/src/wayland-shm.c @@ -25,6 +25,8 @@ * */ +#define _GNU_SOURCE + #include #include #include @@ -38,7 +40,6 @@ struct wl_shm_pool { int refcount; char *data; int size; - int fd; }; struct wl_shm_buffer { @@ -57,7 +58,6 @@ shm_pool_unref(struct wl_shm_pool *pool) return; munmap(pool->data, pool->size); - close(pool->fd); free(pool); } @@ -160,17 +160,15 @@ shm_pool_resize(struct wl_client *client, struct wl_resource *resource, struct wl_shm_pool *pool = resource->data; void *data; - data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, - pool->fd, 0); + data = mremap(pool->data, pool->size, size, MREMAP_MAYMOVE); if (data == MAP_FAILED) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD, - "failed mmap fd %d", pool->fd); + "failed mremap"); return; } - munmap(pool->data, pool->size); pool->data = data; pool->size = size; } @@ -203,10 +201,10 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource, } pool->refcount = 1; - pool->fd = fd; pool->size = size; pool->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + close(fd); if (pool->data == MAP_FAILED) { wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD,