mesa: consistantly use mesa memory-functions in gallium state tracker
[mesa.git] / src / mesa / state_tracker / st_cb_program.c
index 3154fc85aa439da5f109b6fea99eb99b89b13e67..44f47865f80147282867b7af8ec3f152951478f2 100644 (file)
@@ -89,8 +89,12 @@ static void st_use_program( GLcontext *ctx,
 
 
 
+/**
+ * Called via ctx->Driver.NewProgram() to allocate a new vertex or
+ * fragment program.
+ */
 static struct gl_program *st_new_program( GLcontext *ctx,
-                                         GLenum target, 
+                                         GLenum target,
                                          GLuint id )
 {
    switch (target) {
@@ -118,7 +122,8 @@ static struct gl_program *st_new_program( GLcontext *ctx,
    }
 
    default:
-      return _mesa_new_program(ctx, target, id);
+      assert(0);
+      return NULL;
    }
 }
 
@@ -138,8 +143,16 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
             stvp->driver_shader = NULL;
          }
 
+         if (stvp->draw_shader) {
+#if FEATURE_feedback || FEATURE_drawpix
+            /* this would only have been allocated for the RasterPos path */
+            draw_delete_vertex_shader(st->draw, stvp->draw_shader);
+            stvp->draw_shader = NULL;
+#endif
+         }
+
          if (stvp->state.tokens) {
-            FREE((void *) stvp->state.tokens);
+            _mesa_free((void *) stvp->state.tokens);
             stvp->state.tokens = NULL;
          }
       }
@@ -154,7 +167,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
          }
          
          if (stfp->state.tokens) {
-            FREE((void *) stfp->state.tokens);
+            _mesa_free((void *) stfp->state.tokens);
             stfp->state.tokens = NULL;
          }
 
@@ -201,7 +214,7 @@ static void st_program_string_notify( GLcontext *ctx,
       }
 
       if (stfp->state.tokens) {
-         FREE((void *) stfp->state.tokens);
+         _mesa_free((void *) stfp->state.tokens);
          stfp->state.tokens = NULL;
       }
 
@@ -221,12 +234,15 @@ static void st_program_string_notify( GLcontext *ctx,
       }
 
       if (stvp->draw_shader) {
+#if FEATURE_feedback || FEATURE_drawpix
+         /* this would only have been allocated for the RasterPos path */
          draw_delete_vertex_shader(st->draw, stvp->draw_shader);
          stvp->draw_shader = NULL;
+#endif
       }
 
       if (stvp->state.tokens) {
-         FREE((void *) stvp->state.tokens);
+         _mesa_free((void *) stvp->state.tokens);
          stvp->state.tokens = NULL;
       }