From: Brian Paul Date: Fri, 2 Dec 2005 19:41:43 +0000 (+0000) Subject: Fix two failures encountered when running out of memory during XImage X-Git-Tag: 062012170305~21602 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99f13343cf270d8dfde8445ae363d9b05256e05b;p=profile%2Fivi%2Fmesa.git Fix two failures encountered when running out of memory during XImage allocation. Append \n to _mesa_warning() strings. --- diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index aa0f891..2bcbd2c 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -509,7 +509,7 @@ alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height) ZPixmap, NULL, &b->shminfo, width, height); if (b->backxrb->ximage == NULL) { - _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling."); + _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.\n"); b->shm = 0; return GL_FALSE; } @@ -517,10 +517,10 @@ alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->shminfo.shmid = shmget( IPC_PRIVATE, b->backxrb->ximage->bytes_per_line * b->backxrb->ximage->height, IPC_CREAT|0777 ); if (b->shminfo.shmid < 0) { - _mesa_warning(NULL, "shmget failed while allocating back buffer"); + _mesa_warning(NULL, "shmget failed while allocating back buffer.\n"); XDestroyImage( b->backxrb->ximage ); b->backxrb->ximage = NULL; - _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling."); + _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling.\n"); b->shm = 0; return GL_FALSE; } @@ -528,11 +528,11 @@ alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height) b->shminfo.shmaddr = b->backxrb->ximage->data = (char*)shmat( b->shminfo.shmid, 0, 0 ); if (b->shminfo.shmaddr == (char *) -1) { - _mesa_warning(NULL, "shmat() failed while allocating back buffer"); + _mesa_warning(NULL, "shmat() failed while allocating back buffer.\n"); XDestroyImage( b->backxrb->ximage ); shmctl( b->shminfo.shmid, IPC_RMID, 0 ); b->backxrb->ximage = NULL; - _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling."); + _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling.\n"); b->shm = 0; return GL_FALSE; } @@ -631,21 +631,23 @@ xmesa_alloc_back_buffer( XMesaBuffer b, GLuint width, GLuint height ) 8, 0 ); /* pad, bytes_per_line */ #endif if (!b->backxrb->ximage) { - _mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed."); + _mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.\n"); return; } b->backxrb->ximage->data = (char *) MALLOC( b->backxrb->ximage->height * b->backxrb->ximage->bytes_per_line ); if (!b->backxrb->ximage->data) { - _mesa_warning(NULL, "alloc_back_buffer: MALLOC failed."); + _mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.\n"); XMesaDestroyImage( b->backxrb->ximage ); b->backxrb->ximage = NULL; } - /* this call just updates the width/origin fields in the xrb */ - b->backxrb->Base.AllocStorage(NULL, &b->backxrb->Base, - b->backxrb->Base.InternalFormat, - b->backxrb->ximage->width, - b->backxrb->ximage->height); + else { + /* this call just updates the width/origin fields in the xrb */ + b->backxrb->Base.AllocStorage(NULL, &b->backxrb->Base, + b->backxrb->Base.InternalFormat, + b->backxrb->ximage->width, + b->backxrb->ximage->height); + } } b->backxrb->pixmap = None; } @@ -1252,7 +1254,7 @@ static GLboolean initialize_visual_and_buffer( int client, } } else { - _mesa_warning(NULL, "XMesa: RGB mode rendering not supported in given visual."); + _mesa_warning(NULL, "XMesa: RGB mode rendering not supported in given visual.\n"); return GL_FALSE; } v->mesa_visual.indexBits = 0; diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 64a920d..8067b64 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.3 + * Version: 6.5 * * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. * @@ -98,7 +98,8 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1); } else { - assert(xrb->pixmap); + /* this assertion will fail if we happend to run out of memory */ + /*assert(xrb->pixmap);*/ } return GL_TRUE;