mesa/st+tgsi: Provide a free callback to match with ureg_get_tokens().
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 11 May 2010 20:27:05 +0000 (21:27 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 11 May 2010 20:27:22 +0000 (21:27 +0100)
This fixes crashes with the memory debugging routines on Windows.

NOTE: This is a candidate for the 7.8 stable branch

src/gallium/auxiliary/tgsi/tgsi_ureg.c
src/gallium/auxiliary/tgsi/tgsi_ureg.h
src/mesa/state_tracker/st_cb_drawpixels.c

index 49b854b12341dcdd06848e83c0ea68e7b5675856..5fda808dbeff0419cb0c5a6698b75544309bced0 100644 (file)
@@ -1467,6 +1467,12 @@ const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg,
 }
 
 
+void ureg_free_tokens( const struct tgsi_token *tokens )
+{
+   FREE((struct tgsi_token *)tokens);
+}
+
+
 struct ureg_program *ureg_create( unsigned processor )
 {
    struct ureg_program *ureg = CALLOC_STRUCT( ureg_program );
index f32420dd872e1752cc9d0ec9425c374ce99cd70c..055545f3d2aef4e3b93fda570bdf8a183d07f03d 100644 (file)
@@ -104,6 +104,10 @@ ureg_get_tokens( struct ureg_program *ureg,
                  unsigned *nr_tokens );
 
 
+/* Free the tokens created by ureg_get_tokens() */
+void ureg_free_tokens( const struct tgsi_token *tokens );
+
+
 void 
 ureg_destroy( struct ureg_program * );
 
index 3002d3fac36bdeceb2f50c7ac37941d4fb10be21..d8c2fb7ffba656c3bb6573602ba39b3f69d87a0f 100644 (file)
@@ -1140,7 +1140,7 @@ st_destroy_drawpix(struct st_context *st)
    st_reference_fragprog(st, &st->drawpix.z_shader, NULL);
    st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
    if (st->drawpix.vert_shaders[0])
-      free(st->drawpix.vert_shaders[0]);
+      ureg_free_tokens(st->drawpix.vert_shaders[0]);
    if (st->drawpix.vert_shaders[1])
-      free(st->drawpix.vert_shaders[1]);
+      ureg_free_tokens(st->drawpix.vert_shaders[1]);
 }