diff options
author | Brian Paul <[email protected]> | 2010-01-22 13:07:04 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-01-22 13:07:07 -0700 |
commit | efde2df114c2c15212198cb196b50cd29bd75f70 (patch) | |
tree | eb61da285e262fef3a3fa376047d1a5c6baf81c3 /src/gallium/winsys/xlib | |
parent | 64871747bb7b611ffe429fbf1724bd98ee25dd84 (diff) |
xlib/softpipe: more buffer free fixes
The previous memory leak fix didn't always work properly.
Now check the xm_buffer::smh field (now documented!) to
see if the buffer points to shared memory.
Diffstat (limited to 'src/gallium/winsys/xlib')
-rw-r--r-- | src/gallium/winsys/xlib/xlib_softpipe.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index da2484c981f..9769eb00306 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -62,7 +62,7 @@ struct xm_buffer XImage *tempImage; #ifdef USE_XSHM - int shm; + boolean shm; /** Is this a shared memory buffer? */ XShmSegmentInfo shminfo; #endif }; @@ -151,7 +151,7 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb, &b->shminfo, width, height); if (b->tempImage == NULL) { - b->shm = 0; + b->shm = FALSE; return; } @@ -168,12 +168,12 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb, mesaXErrorFlag = 0; XDestroyImage(b->tempImage); b->tempImage = NULL; - b->shm = 0; + b->shm = FALSE; (void) XSetErrorHandler(old_handler); return; } - b->shm = 1; + b->shm = TRUE; } #endif /* USE_XSHM */ @@ -221,12 +221,13 @@ xm_buffer_destroy(struct pipe_buffer *buf) oldBuf->shminfo.shmaddr = (char *) -1; } + if (oldBuf->shm) { + oldBuf->data = NULL; + } + if (oldBuf->tempImage) { - if (oldBuf->data == oldBuf->tempImage->data) { - /* oldBuf->data points at the xshm memory which we'll now free */ - oldBuf->data = NULL; - } XDestroyImage(oldBuf->tempImage); + oldBuf->tempImage = NULL; } #endif @@ -341,10 +342,8 @@ xm_buffer_create(struct pipe_winsys *pws, buffer->base.usage = usage; buffer->base.size = size; - if (buffer->data == NULL) { - /* align to 16-byte multiple for Cell */ - buffer->data = align_malloc(size, max(alignment, 16)); - } + /* align to 16-byte multiple for Cell */ + buffer->data = align_malloc(size, max(alignment, 16)); return &buffer->base; } |