changed to use SDL_realloc()
authorBob Pendleton <bob@pendleton.com>
Thu, 26 Jul 2007 17:58:17 +0000
changeset 221682a133b784c9
parent 2215 23a2cb765052
child 2217 18bca558f3a1
changed to use SDL_realloc()
src/video/x11/SDL_x11gamma.c
     1.1 --- a/src/video/x11/SDL_x11gamma.c	Wed Jul 25 21:23:28 2007 +0000
     1.2 +++ b/src/video/x11/SDL_x11gamma.c	Thu Jul 26 17:58:17 2007 +0000
     1.3 @@ -63,7 +63,6 @@
     1.4                    XStandardColormap * cmap, Visual * visual)
     1.5  {
     1.6      int i;
     1.7 -    cmapTableEntry *newTable = NULL;
     1.8  
     1.9      /* search the table to find out if we already have this one. We
    1.10         only want one entry for each display, screen number, visualid,
    1.11 @@ -79,18 +78,12 @@
    1.12  
    1.13      /* increase the table by one entry. If the table is NULL create the
    1.14         first entrty */
    1.15 -    newTable = SDL_malloc((numCmaps + 1) * sizeof(cmapTableEntry));
    1.16 -    if (NULL == newTable) {
    1.17 +    cmapTable = SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry));
    1.18 +    if (NULL == cmapTable) {
    1.19          SDL_SetError("Out of memory in X11_TrackColormap()");
    1.20          return;
    1.21      }
    1.22  
    1.23 -    if (NULL != cmapTable) {
    1.24 -        SDL_memcpy(newTable, cmapTable, numCmaps * sizeof(cmapTableEntry));
    1.25 -        SDL_free(cmapTable);
    1.26 -    }
    1.27 -    cmapTable = newTable;
    1.28 -
    1.29      cmapTable[numCmaps].display = display;
    1.30      cmapTable[numCmaps].scrNum = scrNum;
    1.31      cmapTable[numCmaps].colormap = colormap;