Avoid redundant reallocation of the template.
authorZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 18:06:19 +0000 (14:06 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 18:06:19 +0000 (14:06 -0400)
cso already allocated the template for us. Returning 0 means
we have no driver specific representation and just want
the template on the bind.

src/mesa/pipe/softpipe/sp_state_blend.c
src/mesa/state_tracker/st_atom_blend.c

index 7a94e82..7fb47e7 100644 (file)
@@ -34,10 +34,9 @@ void *
 softpipe_create_blend_state(struct pipe_context *pipe,
                             const struct pipe_blend_state *blend)
 {
-   struct pipe_blend_state *new_blend = malloc(sizeof(struct pipe_blend_state));
-   memcpy(new_blend, blend, sizeof(struct pipe_blend_state));
-
-   return new_blend;
+   /* means that we just want pipe_blend_state and don't have
+    * anything specific */
+   return 0;
 }
 
 void softpipe_bind_blend_state( struct pipe_context *pipe,
@@ -53,7 +52,7 @@ void softpipe_bind_blend_state( struct pipe_context *pipe,
 void softpipe_delete_blend_state(struct pipe_context *pipe,
                                  void *blend )
 {
-   free(blend);
+   /* do nothing */
 }
 
 
index d5eadc3..f321cd3 100644 (file)
@@ -156,6 +156,7 @@ static void
 update_blend( struct st_context *st )
 {
    struct pipe_blend_state blend;
+   const struct cso_blend *cso;
 
    memset(&blend, 0, sizeof(blend));
 
@@ -211,8 +212,7 @@ update_blend( struct st_context *st )
    if (st->ctx->Color.DitherFlag)
       blend.dither = 1;
 
-   const struct cso_blend *cso =
-      st_cached_blend_state(st, &blend);
+   cso = st_cached_blend_state(st, &blend);
 
    if (st->state.blend != cso) {
       /* state has changed */