tgsi: add info fields for fragcoord origin, center, etc
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_util.c
index e9821de9763769adc01ec016a96aff8a14a8434b..e22e5fed0c6b8c8b26b6647aecc0dd47d617691e 100644 (file)
@@ -30,7 +30,7 @@
   *   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"
 
@@ -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;
 }