Fix two failures encountered when running out of memory during XImage

allocation.
Append \n to _mesa_warning() strings.
This commit is contained in:
Brian Paul
2005-12-02 19:41:43 +00:00
parent 1b3128cc9a
commit 99f13343cf
2 changed files with 18 additions and 15 deletions

View File

@@ -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,22 +631,24 @@ 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;
}
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;
}
else if (b->db_mode == BACK_PIXMAP) {
@@ -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;

View File

@@ -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;