fix vbo display list memleak upon context destruction
authorBrian <brian.paul@tungstengraphics.com>
Fri, 28 Dec 2007 21:52:12 +0000 (14:52 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 1 Jan 2008 17:21:21 +0000 (10:21 -0700)
src/mesa/vbo/vbo_context.c
src/mesa/vbo/vbo_save.c

index 60d0b76..235cee2 100644 (file)
@@ -246,6 +246,7 @@ void _vbo_DestroyContext( GLcontext *ctx )
    }
 
    vbo_exec_destroy(ctx);
+   vbo_save_destroy(ctx);
    FREE(vbo_context(ctx));
    ctx->swtnl_im = NULL;
 }
index 87248e1..8dd8714 100644 (file)
@@ -69,6 +69,21 @@ void vbo_save_init( GLcontext *ctx )
 
 void vbo_save_destroy( GLcontext *ctx )
 {
+   struct vbo_context *vbo = vbo_context(ctx);
+   struct vbo_save_context *save = &vbo->save;
+   if (save->prim_store) {
+      if ( --save->prim_store->refcount == 0 ) {
+         FREE( save->prim_store );
+         save->prim_store = NULL;
+      }
+      if ( --save->vertex_store->refcount == 0 ) {
+         if (save->vertex_store->bufferobj)
+            ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj );
+
+         FREE( save->vertex_store );
+         save->vertex_store = NULL;
+      }
+   }
 }