OSDN Git Service

glx: free vertex array state when context is destroyed
authorKristof Ralovich <kristof.ralovich@gmail.com>
Wed, 20 Aug 2008 21:18:38 +0000 (15:18 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 20 Aug 2008 21:33:03 +0000 (15:33 -0600)
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c
src/glx/x11/indirect_vertex_array.c

index 8143289..e2b4218 100644 (file)
@@ -695,9 +695,10 @@ extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
 
 
 /*
-** Allocate and Initialize Vertex Array client state 
+** Allocate and Initialize Vertex Array client state, and free.
 */
-extern void __glXInitVertexArrayState(__GLXcontext*);
+extern void __glXInitVertexArrayState(__GLXcontext *);
+extern void __glXFreeVertexArrayState(__GLXcontext *);
 
 /*
 ** Inform the Server of the major and minor numbers and of the client
index 6cafb33..0f0cb62 100644 (file)
@@ -532,6 +532,8 @@ DestroyContext(Display *dpy, GLXContext gc)
     }
 #endif
 
+    __glXFreeVertexArrayState(gc);
+
     if (gc->currentDpy) {
        /* Have to free later cuz it's in use now */
        __glXUnlock();
index 15e3ece..c7a20e2 100644 (file)
@@ -101,6 +101,31 @@ const GLuint __glXTypeSize_table[16] = {
 };
 
 
+/**
+ * Free the per-context array state that was allocated with
+ * __glXInitVertexArrayState().
+ */
+void
+__glXFreeVertexArrayState( __GLXcontext * gc )
+{
+    __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+    struct array_state_vector* arrays = state->array_state;
+
+    if (arrays) {
+        if (arrays->stack) {
+            free(arrays->stack);
+            arrays->stack = NULL;
+        }
+        if (arrays->arrays) {
+            free(arrays->arrays);
+            arrays->arrays = NULL;
+        }
+        free(arrays);
+        arrays = NULL;
+        state->array_state = NULL;
+    }
+}
+
 
 /**
  * Initialize vertex array state of a GLX context.