destroy the memory manager along with the context
authorTilman Sauerbeck <tilman@freedesktop.org>
Sun, 11 Jun 2006 09:12:27 +0000 (09:12 +0000)
committerTilman Sauerbeck <tilman@freedesktop.org>
Sun, 11 Jun 2006 09:12:27 +0000 (09:12 +0000)
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/radeon_mm.c
src/mesa/drivers/dri/r300/radeon_mm.h

index ab582525abc4b97ee3df66cc07fa1438a39ddad2..d7f027dcb829e675360bdf703539b35772c28c80 100644 (file)
@@ -486,6 +486,13 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
 
                radeonCleanupContext(&r300->radeon);
 
+#ifdef USER_BUFFERS
+               /* the memory manager might be accessed when Mesa frees the shared
+                * state, so don't destroy it earlier
+                */
+               radeon_mm_destroy(r300);
+#endif
+
                /* free the option cache */
                driDestroyOptionCache(&r300->radeon.optionCache);
 
index 55aa5df01a656a056b8f59525897cf91b01b72d1..ce3c5e4b9abbe733af7089f110dd00a800a2c99f 100644 (file)
@@ -69,6 +69,15 @@ void radeon_mm_init(r300ContextPtr rmesa)
        resize_u_list(rmesa);
 }
 
+void radeon_mm_destroy(r300ContextPtr rmesa)
+{
+       _mesa_free(rmesa->rmm->u_list);
+       rmesa->rmm->u_list = NULL;
+
+       _mesa_free(rmesa->rmm);
+       rmesa->rmm = NULL;
+}
+
 void *radeon_mm_ptr(r300ContextPtr rmesa, int id)
 {
        assert(id <= rmesa->rmm->u_last);
index 9df5224ddeb20bebab369a4742895708d09d3718..81f89917e604f40f1a25f9164a8ea73bfc33154f 100644 (file)
@@ -26,6 +26,7 @@ struct radeon_memory_manager {
 };
 
 extern void radeon_mm_init(r300ContextPtr rmesa);
+extern void radeon_mm_destroy(r300ContextPtr rmesa);
 extern void *radeon_mm_ptr(r300ContextPtr rmesa, int id);
 extern int radeon_mm_find(r300ContextPtr rmesa, void *ptr);
 extern int radeon_mm_alloc(r300ContextPtr rmesa, int alignment, int size);