diff src/video/x11/SDL_x11opengl.c @ 2322:c25d45b7add3

Fixing valgrind errors. One of the error was the result of an unitended recursive call to X11_GL_LoadLibrary which was also fixed.
author Bob Pendleton <bob@pendleton.com>
date Thu, 06 Mar 2008 17:08:10 +0000
parents 166400aa33d7
children 4ac07ae446d3
line wrap: on
line diff
--- 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)
 {