loader: #define PATH_MAX when undefined (eg. Hurd)
[mesa.git] / src / mesa / program / arbprogparse.c
index 196d30f4dafab295caa3d2a09008ad7c4165b306..99aa6914624e6d0f8f83cecac49b7b6693d827a1 100644 (file)
@@ -78,6 +78,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
    memset(&prog, 0, sizeof(prog));
    memset(&state, 0, sizeof(state));
    state.prog = &prog;
+   state.mem_ctx = program;
 
    if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len,
                                &state)) {
@@ -85,7 +86,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
       return;
    }
 
-   free(program->String);
+   ralloc_free(program->String);
 
    /* Copy the relevant contents of the arb_program struct into the
     * fragment_program struct.
@@ -116,12 +117,12 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
          program->SamplersUsed |= (1 << i);
    }
    program->ShadowSamplers = prog.ShadowSamplers;
-   program->OriginUpperLeft = state.option.OriginUpperLeft;
-   program->PixelCenterInteger = state.option.PixelCenterInteger;
+   program->info.fs.origin_upper_left = state.option.OriginUpperLeft;
+   program->info.fs.pixel_center_integer = state.option.PixelCenterInteger;
 
    program->info.fs.uses_discard = state.fragment.UsesKill;
 
-   free(program->arb.Instructions);
+   ralloc_free(program->arb.Instructions);
    program->arb.Instructions = prog.arb.Instructions;
 
    if (program->Parameters)
@@ -174,14 +175,11 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
 
    if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len,
                                &state)) {
-      ralloc_free(prog.arb.Instructions);
-      ralloc_free(prog.String);
       _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)");
       return;
    }
 
-   if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
-      _mesa_optimize_program(ctx, &prog, program);
+   _mesa_optimize_program(&prog, program);
 
    ralloc_free(program->String);