glx: realloc style fix in RenderLarge
authorAdam Jackson <ajax@redhat.com>
Tue, 2 Jul 2013 14:35:19 +0000 (10:35 -0400)
committerAdam Jackson <ajax@redhat.com>
Wed, 11 Sep 2013 18:37:32 +0000 (14:37 -0400)
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
glx/glxcmds.c

index b817e5a..9deadb7 100644 (file)
@@ -2176,15 +2176,12 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
          ** Make enough space in the buffer, then copy the entire request.
          */
         if (cl->largeCmdBufSize < cmdlen) {
-            if (!cl->largeCmdBuf) {
-                cl->largeCmdBuf = (GLbyte *) malloc(cmdlen);
-            }
-            else {
-                cl->largeCmdBuf = (GLbyte *) realloc(cl->largeCmdBuf, cmdlen);
-            }
-            if (!cl->largeCmdBuf) {
-                return BadAlloc;
-            }
+           GLbyte *newbuf = cl->largeCmdBuf;
+
+           if (!(newbuf = realloc(newbuf, cmdlen)))
+               return BadAlloc;
+
+           cl->largeCmdBuf = newbuf;
             cl->largeCmdBufSize = cmdlen;
         }
         memcpy(cl->largeCmdBuf, pc, dataBytes);