diff src/video/x11/SDL_x11gamma.c @ 2216:82a133b784c9

changed to use SDL_realloc()
author Bob Pendleton <bob@pendleton.com>
date Thu, 26 Jul 2007 17:58:17 +0000
parents e7164a4dac62
children 1d75c38e1e5c
line wrap: on
line diff
--- a/src/video/x11/SDL_x11gamma.c	Wed Jul 25 21:23:28 2007 +0000
+++ b/src/video/x11/SDL_x11gamma.c	Thu Jul 26 17:58:17 2007 +0000
@@ -63,7 +63,6 @@
                   XStandardColormap * cmap, Visual * visual)
 {
     int i;
-    cmapTableEntry *newTable = NULL;
 
     /* search the table to find out if we already have this one. We
        only want one entry for each display, screen number, visualid,
@@ -79,18 +78,12 @@
 
     /* increase the table by one entry. If the table is NULL create the
        first entrty */
-    newTable = SDL_malloc((numCmaps + 1) * sizeof(cmapTableEntry));
-    if (NULL == newTable) {
+    cmapTable = SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry));
+    if (NULL == cmapTable) {
         SDL_SetError("Out of memory in X11_TrackColormap()");
         return;
     }
 
-    if (NULL != cmapTable) {
-        SDL_memcpy(newTable, cmapTable, numCmaps * sizeof(cmapTableEntry));
-        SDL_free(cmapTable);
-    }
-    cmapTable = newTable;
-
     cmapTable[numCmaps].display = display;
     cmapTable[numCmaps].scrNum = scrNum;
     cmapTable[numCmaps].colormap = colormap;