summaryrefslogtreecommitdiff
path: root/src/mesa/x86
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-11-03 08:50:55 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-11-03 08:50:55 -0600
commit417cb2c1829f2119f6674987edac09c61d633b45 (patch)
tree588bc608bfa50ef25dde492a332f23c87f1d732f /src/mesa/x86
parentd9276cbb29807cbca5d7be9a0cedfeb1dcbfbd9c (diff)
Fix mem leak in SSE code generation path (Michel Dänzer) and don't crash if _mesa_exec_malloc() returns NULL.
(picked from mesa_7_0_branch)
Diffstat (limited to 'src/mesa/x86')
-rw-r--r--src/mesa/x86/rtasm/x86sse.c25
-rw-r--r--src/mesa/x86/rtasm/x86sse.h3
2 files changed, 18 insertions, 10 deletions
diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c
index 3ea37bb5e7..612cd51a6e 100644
--- a/src/mesa/x86/rtasm/x86sse.c
+++ b/src/mesa/x86/rtasm/x86sse.c
@@ -1063,20 +1063,29 @@ struct x86_reg x86_fn_arg( struct x86_function *p,
}
-void x86_init_func( struct x86_function *p )
-{
- x86_init_func_size(p, 1024);
-}
-
-void x86_init_func_size( struct x86_function *p, GLuint code_size )
+/**
+ * Initialize an x86_function object, allocating space for up to
+ * 'code_size' bytes of code.
+ */
+GLboolean x86_init_func( struct x86_function *p, GLuint code_size )
{
+ assert(!p->store);
p->store = _mesa_exec_malloc(code_size);
- p->csr = p->store;
+ if (p->store) {
+ p->csr = p->store;
+ return GL_TRUE;
+ }
+ else {
+ p->csr = NULL;
+ return GL_FALSE;
+ }
}
void x86_release_func( struct x86_function *p )
{
- _mesa_exec_free(p->store);
+ if (p->store)
+ _mesa_exec_free(p->store);
+ p->store = p->csr = NULL;
}
diff --git a/src/mesa/x86/rtasm/x86sse.h b/src/mesa/x86/rtasm/x86sse.h
index 66fb852ac9..42b09937bc 100644
--- a/src/mesa/x86/rtasm/x86sse.h
+++ b/src/mesa/x86/rtasm/x86sse.h
@@ -80,8 +80,7 @@ enum sse_cc {
*/
-void x86_init_func( struct x86_function *p );
-void x86_init_func_size( struct x86_function *p, GLuint code_size );
+GLboolean x86_init_func( struct x86_function *p, GLuint code_size );
void x86_release_func( struct x86_function *p );
void (*x86_get_func( struct x86_function *p ))( void );