From edbc302ad678e1a4a8803ba0e827a13dd27105d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 11 May 2010 21:27:05 +0100 Subject: [PATCH] mesa/st+tgsi: Provide a free callback to match with ureg_get_tokens(). 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 | 6 ++++++ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 4 ++++ src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 49b854b1234..5fda808dbef 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -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 ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index f32420dd872..055545f3d2a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -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 * ); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 3002d3fac36..d8c2fb7ffba 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -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]); } -- 2.30.2