mesa: fix-up and use _mesa_delete_renderbuffer()
authorBrian Paul <brianp@vmware.com>
Thu, 30 Aug 2012 15:27:16 +0000 (09:27 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 31 Aug 2012 14:04:40 +0000 (08:04 -0600)
_mesa_delete_renderbuffer() should free the mutex (though that may be a
no-op) and then free the renderbuffer object itself.  Subclasses of
gl_renderbuffer can use this function too.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/nouveau/nouveau_fbo.c
src/mesa/drivers/dri/radeon/radeon_fbo.c
src/mesa/drivers/dri/swrast/swrast.c
src/mesa/main/renderbuffer.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/swrast/s_renderbuffer.c

index ad78e0a29d8706ba5432cd7711c71cca18aa1f7f..c522b486bcf47e4e09ac665f87daf3031471e41c 100644 (file)
@@ -95,7 +95,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
 
    intel_miptree_release(&irb->mt);
 
-   free(irb);
+   _mesa_delete_renderbuffer(rb);
 }
 
 /**
index 50eb1824354470df9a1ff55495b0fe567198bf84..3be958bbca7a2d9e4165b2df08875ffa6178ad47 100644 (file)
@@ -107,7 +107,7 @@ nouveau_renderbuffer_del(struct gl_renderbuffer *rb)
        struct nouveau_surface *s = &to_nouveau_renderbuffer(rb)->surface;
 
        nouveau_surface_ref(NULL, s);
-       FREE(rb);
+       _mesa_delete_renderbuffer(rb);
 }
 
 static struct gl_renderbuffer *
index 9032a323a3f8d8b72f7ba6fae5f9d1a87c419760..2267a10b6418a4d1877f6582dd9195a6efa714e3 100644 (file)
@@ -67,7 +67,7 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb)
   if (rrb && rrb->bo) {
     radeon_bo_unref(rrb->bo);
   }
-  free(rrb);
+  _mesa_delete_renderbuffer(rb);
 }
 
 #if defined(RADEON_R100)
index 9aed2f6e6c55e085c24c7c6eacb66b3f498a0c0c..f0ff0b0aaf3f523184f3866f716a422656143f14 100644 (file)
@@ -268,7 +268,7 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
     TRACE;
 
     free(xrb->Base.Buffer);
-    free(xrb);
+    _mesa_delete_renderbuffer(rb);
 }
 
 /* see bytes_per_line in libGL */
index 1bb09bfe6a18ff413aa21fef0f8fa7f10f0c721f..26f53d1009d366e6c3341f7ccc393a5573c5a78a 100644 (file)
@@ -75,11 +75,15 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
 /**
  * Delete a gl_framebuffer.
  * This is the default function for renderbuffer->Delete().
+ * Drivers which subclass gl_renderbuffer should probably implement their
+ * own delete function.  But the driver might also call this function to
+ * free the object in the end.
  */
 void
 _mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
 {
-   /* no-op */
+   _glthread_DESTROY_MUTEX(rb->Mutex);
+   free(rb);
 }
 
 
index 40e3677f6af0a72eed4913b45690136c3341a211..01aba8eaff1d723f4db4e14f7c1cee25727efc13 100644 (file)
@@ -232,7 +232,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
    pipe_surface_reference(&strb->surface, NULL);
    pipe_resource_reference(&strb->texture, NULL);
    free(strb->data);
-   free(strb);
+   _mesa_delete_renderbuffer(rb);
 }
 
 
index d8a7467b08daaae40ca919876daa5a88c357fac0..e468bdb16b0abb534e1870225f089fdf70c0548b 100644 (file)
@@ -174,7 +174,7 @@ soft_renderbuffer_delete(struct gl_renderbuffer *rb)
       free(srb->Buffer);
       srb->Buffer = NULL;
    }
-   free(srb);
+   _mesa_delete_renderbuffer(rb);
 }