summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/draw/draw_pipe_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_pipe_util.c')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_util.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_util.c b/src/gallium/auxiliary/draw/draw_pipe_util.c
index e9821de976..04438f4dd0 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_util.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_util.c
@@ -68,24 +68,28 @@ draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header)
*/
boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
{
- unsigned i;
- ubyte *store;
-
assert(!stage->tmp);
stage->tmp = NULL;
stage->nr_tmps = nr;
- if (nr == 0)
- return FALSE;
- store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
- if (store == NULL)
- return FALSE;
+ if (nr != 0)
+ {
+ unsigned i;
+ ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
+
+ if (store == NULL)
+ return FALSE;
- stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
-
- for (i = 0; i < nr; i++)
- stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+ stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
+ if (stage->tmp == NULL) {
+ FREE(store);
+ return FALSE;
+ }
+
+ for (i = 0; i < nr; i++)
+ stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
+ }
return TRUE;
}