diff options
author | Keith Whitwell <[email protected]> | 2001-04-30 21:08:51 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-04-30 21:08:51 +0000 |
commit | 0e14d6d68eae5b9a3f8d21d63d8129db947e3580 (patch) | |
tree | d13e7d5bbac6a09c4e2eaa82013d4ef2e2cea4c5 /src/mesa/tnl/t_imm_alloc.c | |
parent | 16837e4219e03df36c34f08cee1967b946c44536 (diff) |
Lots more eval fixes
Diffstat (limited to 'src/mesa/tnl/t_imm_alloc.c')
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index def3b9cc6cd..2b497a70583 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.c,v 1.6 2001/04/26 14:53:48 keithw Exp $ */ +/* $Id: t_imm_alloc.c,v 1.7 2001/04/30 21:08:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -36,7 +36,7 @@ static int id = 0; -struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) +static struct immediate *real_alloc_immediate( GLcontext *ctx ) { struct immediate *IM = ALIGN_MALLOC_STRUCT( immediate, 32 ); GLuint j; @@ -81,7 +81,7 @@ struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) } -void _tnl_free_immediate( struct immediate *IM ) +static void real_free_immediate( struct immediate *IM ) { static int freed = 0; GLuint j; @@ -101,3 +101,31 @@ void _tnl_free_immediate( struct immediate *IM ) freed++; /* printf("outstanding %d\n", id - freed); */ } + + +/* Cache a single allocated immediate struct. + */ +struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct immediate *tmp = tnl->freed_immediate; + + if (tmp) { + tnl->freed_immediate = 0; + return tmp; + } + else + return real_alloc_immediate( ctx ); +} + +void _tnl_free_immediate( struct immediate *IM ) +{ + TNLcontext *tnl = TNL_CONTEXT(IM->backref); + + ASSERT(IM->ref_count == 0); + + if (tnl->freed_immediate) + real_free_immediate( tnl->freed_immediate ); + + tnl->freed_immediate = IM; +} |