# HG changeset patch # User Bob Pendleton # Date 1204823290 0 # Node ID c25d45b7add311ca8b9247a754ca2659ba8a27c1 # Parent c5feceb0395e876bec2a98a9865aae27e40f59fa Fixing valgrind errors. One of the error was the result of an unitended recursive call to X11_GL_LoadLibrary which was also fixed. diff -r c5feceb0395e -r c25d45b7add3 src/SDL_compat.c --- a/src/SDL_compat.c Tue Mar 04 23:09:28 2008 +0000 +++ b/src/SDL_compat.c Thu Mar 06 17:08:10 2008 +0000 @@ -397,8 +397,8 @@ } if (SDL_VideoWindow) { SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y); + SDL_DestroyWindow(SDL_VideoWindow); } - SDL_DestroyWindow(SDL_VideoWindow); /* Set up the event filter */ if (!SDL_GetEventFilter(NULL, NULL)) { diff -r c5feceb0395e -r c25d45b7add3 src/video/x11/SDL_x11opengl.c --- a/src/video/x11/SDL_x11opengl.c Tue Mar 04 23:09:28 2008 +0000 +++ b/src/video/x11/SDL_x11opengl.c Thu Mar 06 17:08:10 2008 +0000 @@ -65,6 +65,8 @@ #define GL_UnloadObject SDL_UnloadObject #endif +static int X11_GL_InitializeMemory(_THIS); + int X11_GL_LoadLibrary(_THIS, const char *path) { @@ -90,7 +92,8 @@ return -1; } // LoadLibrary may be called before WindowCreate! - X11_GL_Initialize(_this); + // Must create the memory used by GL + X11_GL_InitializeMemory(_this); /* Load new function pointers */ _this->gl_data->glXGetProcAddress = @@ -254,11 +257,10 @@ /* X11_PumpEvents(_this); */ /* can't do that because the windowlist may be inconsitent at this point */ } -int -X11_GL_Initialize(_THIS) +static int +X11_GL_InitializeMemory(_THIS) { if (_this->gl_data) { - ++_this->gl_data->initialized; return 0; } @@ -270,18 +272,30 @@ SDL_OutOfMemory(); return -1; } - _this->gl_data->initialized = 1; - - if (X11_GL_LoadLibrary(_this, NULL) < 0) { - return -1; - } - - /* Initialize extensions */ - X11_GL_InitExtensions(_this); + _this->gl_data->initialized = 0; return 0; } +int +X11_GL_Initialize(_THIS) +{ + + if (X11_GL_InitializeMemory(_this) < 0) { + return -1; + } + ++_this->gl_data->initialized; + + if (X11_GL_LoadLibrary(_this, NULL) < 0) { + return -1; + } + + /* Initialize extensions */ + X11_GL_InitExtensions(_this); + + return 0; +} + void X11_GL_Shutdown(_THIS) { diff -r c5feceb0395e -r c25d45b7add3 src/video/x11/SDL_x11window.c --- a/src/video/x11/SDL_x11window.c Tue Mar 04 23:09:28 2008 +0000 +++ b/src/video/x11/SDL_x11window.c Thu Mar 06 17:08:10 2008 +0000 @@ -56,20 +56,6 @@ data->created = created; data->videodata = videodata; - /* Associate the data with the window */ - windowlist = - (SDL_WindowData **) SDL_realloc(windowlist, - (numwindows + - 1) * sizeof(*windowlist)); - if (!windowlist) { - SDL_OutOfMemory(); - SDL_free(data); - return -1; - } - windowlist[numwindows++] = data; - videodata->numwindows = numwindows; - videodata->windowlist = windowlist; - /* Fill in the SDL window with the window data */ { XWindowAttributes attrib; @@ -228,6 +214,7 @@ return -1; } SDL_memcpy(&cmap, stdmaps, sizeof(XStandardColormap)); + XFree(stdmaps); } /* OK, we have the best color map, now copy it for use by the @@ -655,6 +642,7 @@ XDestroyWindow(display, data->window); } SDL_free(data); + window->driverdata = NULL; } }