kwo pushed a commit to branch master. http://git.enlightenment.org/legacy/imlib2.git/commit/?id=56ca24fc9f240061eee9a8e62dbd65a9ba761cca
commit 56ca24fc9f240061eee9a8e62dbd65a9ba761cca Author: Alexander Volkov <[email protected]> Date: Tue Feb 6 16:04:13 2018 +0100 introduce __imlib_ShmDestroyXImage() instead of __imlib_ShmDetach() Summary: It enhances the code, because __imlib_ShmDestroyXImage() is symmetrical to __imlib_ShmGetXImage(), while __imlib_ShmDetach() looks unrelated. Reviewers: kwo Reviewed By: kwo Differential Revision: https://phab.enlightenment.org/D5787 --- src/lib/grab.c | 11 +++++++---- src/lib/ximage.c | 10 +++++++--- src/lib/ximage.h | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib/grab.c b/src/lib/grab.c index c4239f4..b9b8ec8 100644 --- a/src/lib/grab.c +++ b/src/lib/grab.c @@ -733,13 +733,16 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh, /* destroy the Ximage */ if (is_shm) - __imlib_ShmDetach(d, &shminfo); - XDestroyImage(xim); + __imlib_ShmDestroyXImage(d, xim, &shminfo); + else + XDestroyImage(xim); + if (mxim) { if (is_mshm) - __imlib_ShmDetach(d, &mshminfo); - XDestroyImage(mxim); + __imlib_ShmDestroyXImage(d, mxim, &mshminfo); + else + XDestroyImage(mxim); } if (created_mask) XFreePixmap(d, m); diff --git a/src/lib/ximage.c b/src/lib/ximage.c index c94f725..96327f1 100644 --- a/src/lib/ximage.c +++ b/src/lib/ximage.c @@ -119,12 +119,13 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth, } void -__imlib_ShmDetach(Display * d, XShmSegmentInfo * si) +__imlib_ShmDestroyXImage(Display * d, XImage * xim, XShmSegmentInfo * si) { XSync(d, False); XShmDetach(d, si); shmdt(si->shmaddr); shmctl(si->shmid, IPC_RMID, 0); + XDestroyImage(xim); } /* "safe" realloc allowing handling of out-of-memory situations */ @@ -190,10 +191,13 @@ __imlib_FlushXImage(Display * d) list_mem_use -= xim->bytes_per_line * xim->height; if (list_si[i]) { - __imlib_ShmDetach(d, list_si[i]); + __imlib_ShmDestroyXImage(d, xim, list_si[i]); free(list_si[i]); } - XDestroyImage(xim); + else + { + XDestroyImage(xim); + } list_num--; for (j = i; j < list_num; j++) { diff --git a/src/lib/ximage.h b/src/lib/ximage.h index 2a7006e..f12757c 100644 --- a/src/lib/ximage.h +++ b/src/lib/ximage.h @@ -17,6 +17,7 @@ XImage *__imlib_ProduceXImage(Display * d, Visual * v, int depth, XImage *__imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth, int x, int y, int w, int h, XShmSegmentInfo * si); -void __imlib_ShmDetach(Display * d, XShmSegmentInfo * si); +void __imlib_ShmDestroyXImage(Display * d, XImage * xim, + XShmSegmentInfo * si); #endif --
