summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_imm_alloc.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-04-30 21:08:51 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-04-30 21:08:51 +0000
commit0e14d6d68eae5b9a3f8d21d63d8129db947e3580 (patch)
treed13e7d5bbac6a09c4e2eaa82013d4ef2e2cea4c5 /src/mesa/tnl/t_imm_alloc.c
parent16837e4219e03df36c34f08cee1967b946c44536 (diff)
Lots more eval fixes
Diffstat (limited to 'src/mesa/tnl/t_imm_alloc.c')
-rw-r--r--src/mesa/tnl/t_imm_alloc.c34
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 def3b9cc6c..2b497a7058 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;
+}