* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"
*/
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;
}