hi, this drops calling calloc/free each function call.
as a result this makes _mesa_get_fixed_func_vertex_program very similar to
_mesa_get_fixed_func_fragment_program.
>From c6b1a3dfa40d277d06581bce85352407210f444e Mon Sep 17 00:00:00 2001
From: Shunichi Fuji <[EMAIL PROTECTED]>
Date: Fri, 26 Sep 2008 18:55:13 +0900
Subject: [PATCH] mesa: drop calloc from _mesa_get_fixed_func_vertex_program


Signed-off-by: Shunichi Fuji <[EMAIL PROTECTED]>
---
 src/mesa/main/ffvertex_prog.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 787672b..c5ff7a3 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -178,12 +178,12 @@ static GLboolean check_active_shininess( GLcontext *ctx,
 
 
 
-static struct state_key *make_state_key( GLcontext *ctx )
+static void make_state_key( GLcontext *ctx, struct state_key *key )
 {
    const struct gl_fragment_program *fp;
-   struct state_key *key = CALLOC_STRUCT(state_key);
    GLuint i;
 
+   memset(key, 0, sizeof(struct state_key));
    fp = ctx->FragmentProgram._Current;
 
    /* This now relies on texenvprogram.c being active:
@@ -301,8 +301,6 @@ static struct state_key *make_state_key( GLcontext *ctx )
 			      texUnit->GenModeQ );
       }
    }
-   
-   return key;
 }
 
 
@@ -1714,16 +1712,16 @@ struct gl_vertex_program *
 _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
 {
    struct gl_vertex_program *prog;
-   struct state_key *key;
+   struct state_key key;
 
    /* Grab all the relevent state and put it in a single structure:
     */
-   key = make_state_key(ctx);
+   make_state_key(ctx, &key);
 
    /* Look for an already-prepared program for this state:
     */
    prog = (struct gl_vertex_program *)
-      _mesa_search_program_cache(ctx->VertexProgram.Cache, key, sizeof(*key));
+      _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key));
    
    if (!prog) {
       /* OK, we'll have to build a new one */
@@ -1735,7 +1733,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
       if (!prog)
          return NULL;
 
-      create_new_program( key, prog,
+      create_new_program( &key, prog,
                           ctx->Const.VertexProgram.MaxTemps );
 
 #if 0
@@ -1744,10 +1742,8 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
                                           &prog->Base );
 #endif
       _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
-                                 key, sizeof(*key), &prog->Base);
+                                 &key, sizeof(key), &prog->Base);
    }
 
-   _mesa_free(key);
-
    return prog;
 }
-- 
1.6.0.2

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to