r600g: release query buffers in destroy_query
authorMarek Olšák <maraeo@gmail.com>
Thu, 23 Feb 2012 21:45:45 +0000 (22:45 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 5 Mar 2012 13:22:19 +0000 (14:22 +0100)
This fixes a memory leak introduced with the rework.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r600/r600_query.c

index a896f03b0d87e41cb23f68f0daa099f67acf9d1b..25731c290f69960c175790199a37ec55c2cd6774 100644 (file)
@@ -264,6 +264,15 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q
 static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
 {
        struct r600_query *rquery = (struct r600_query*)query;
+       struct r600_query_buffer *prev = rquery->buffer.previous;
+
+       /* Release all query buffers. */
+       while (prev) {
+               struct r600_query_buffer *qbuf = prev;
+               prev = prev->previous;
+               pipe_resource_reference((struct pipe_resource**)&qbuf->buf, NULL);
+               FREE(qbuf);
+       }
 
        pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL);
        FREE(query);