Decrement the context's refcounts on part-used storage structs on
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 9 Aug 2005 16:11:28 +0000 (16:11 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 9 Aug 2005 16:11:28 +0000 (16:11 +0000)
context destroy.  Fixes memory leak.

src/mesa/tnl/t_save_api.c

index b3637cf..b43b048 100644 (file)
@@ -1708,5 +1708,15 @@ void _tnl_save_init( GLcontext *ctx )
  */
 void _tnl_save_destroy( GLcontext *ctx )
 {
-   (void) ctx;
+   TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+   /* Decrement the refcounts.  References may still be held by
+    * display lists yet to be destroyed, so it may not yet be time to
+    * free these items.
+    */
+   if ( --tnl->save.prim_store->refcount == 0 )
+      FREE( tnl->save.prim_store );
+
+   if ( --tnl->save.vertex_store->refcount == 0 )
+      FREE( tnl->save.vertex_store );
 }