Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
2215:23a2cb765052 | 2216:82a133b784c9 |
---|---|
61 void | 61 void |
62 X11_TrackColormap(Display * display, int scrNum, Colormap colormap, | 62 X11_TrackColormap(Display * display, int scrNum, Colormap colormap, |
63 XStandardColormap * cmap, Visual * visual) | 63 XStandardColormap * cmap, Visual * visual) |
64 { | 64 { |
65 int i; | 65 int i; |
66 cmapTableEntry *newTable = NULL; | |
67 | 66 |
68 /* search the table to find out if we already have this one. We | 67 /* search the table to find out if we already have this one. We |
69 only want one entry for each display, screen number, visualid, | 68 only want one entry for each display, screen number, visualid, |
70 and colormap combination */ | 69 and colormap combination */ |
71 for (i = 0; i < numCmaps; i++) { | 70 for (i = 0; i < numCmaps; i++) { |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 /* increase the table by one entry. If the table is NULL create the | 79 /* increase the table by one entry. If the table is NULL create the |
81 first entrty */ | 80 first entrty */ |
82 newTable = SDL_malloc((numCmaps + 1) * sizeof(cmapTableEntry)); | 81 cmapTable = SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry)); |
83 if (NULL == newTable) { | 82 if (NULL == cmapTable) { |
84 SDL_SetError("Out of memory in X11_TrackColormap()"); | 83 SDL_SetError("Out of memory in X11_TrackColormap()"); |
85 return; | 84 return; |
86 } | 85 } |
87 | |
88 if (NULL != cmapTable) { | |
89 SDL_memcpy(newTable, cmapTable, numCmaps * sizeof(cmapTableEntry)); | |
90 SDL_free(cmapTable); | |
91 } | |
92 cmapTable = newTable; | |
93 | 86 |
94 cmapTable[numCmaps].display = display; | 87 cmapTable[numCmaps].display = display; |
95 cmapTable[numCmaps].scrNum = scrNum; | 88 cmapTable[numCmaps].scrNum = scrNum; |
96 cmapTable[numCmaps].colormap = colormap; | 89 cmapTable[numCmaps].colormap = colormap; |
97 SDL_memcpy(&cmapTable[numCmaps].cmap, cmap, sizeof(XStandardColormap)); | 90 SDL_memcpy(&cmapTable[numCmaps].cmap, cmap, sizeof(XStandardColormap)); |