From 9a64440154319738445e203339156e54232908ee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Sep 2008 15:05:03 -0600 Subject: mesa: fix minor mem leak --- src/mesa/shader/prog_print.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 10c5afec18..ec260f18a9 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -250,7 +250,9 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode, { struct gl_program_parameter *param = prog->Parameters->Parameters + index; - sprintf(str, _mesa_program_state_string(param->StateIndexes)); + char *state = _mesa_program_state_string(param->StateIndexes); + sprintf(str, state); + _mesa_free(state); } break; case PROGRAM_ADDRESS: -- cgit v1.2.3 From ce3cf63251b9d0de1de066f71d0c642360215f13 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 5 Sep 2008 12:25:50 +0200 Subject: mesa: _mesa_program_state_string() returns char *, not const char *. --- src/mesa/shader/arbprogparse.c | 4 ++-- src/mesa/shader/prog_parameter.c | 4 ++-- src/mesa/shader/prog_statevars.c | 2 +- src/mesa/shader/prog_statevars.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 78cc6aa9cc..26ccdc7395 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -3354,11 +3354,11 @@ debug_variables (GLcontext * ctx, struct var_cache *vc_head, fprintf (stderr, "%s\n", Program->Base.Parameters->Parameters[a + b].Name); if (Program->Base.Parameters->Parameters[a + b].Type == PROGRAM_STATE_VAR) { - const char *s; + char *s; s = _mesa_program_state_string(Program->Base.Parameters->Parameters [a + b].StateIndexes); fprintf(stderr, "%s\n", s); - _mesa_free((char *) s); + _mesa_free(s); } else fprintf (stderr, "%f %f %f %f\n", diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 2dfd923a0f..bfe27d2f63 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -420,7 +420,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, const gl_state_index stateTokens[STATE_LENGTH]) { const GLuint size = 4; /* XXX fix */ - const char *name; + char *name; GLint index; /* Check if the state reference is already in the list */ @@ -447,7 +447,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, paramList->StateFlags |= _mesa_program_state_flags(stateTokens); /* free name string here since we duplicated it in add_parameter() */ - _mesa_free((void *) name); + _mesa_free(name); return index; } diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 819db25a00..8acf37c3c0 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -767,7 +767,7 @@ append_index(char *dst, GLint index) * For example, return "state.matrix.texture[2].inverse". * Use _mesa_free() to deallocate the string. */ -const char * +char * _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) { char str[1000] = ""; diff --git a/src/mesa/shader/prog_statevars.h b/src/mesa/shader/prog_statevars.h index 0a1c235828..7b490e3d63 100644 --- a/src/mesa/shader/prog_statevars.h +++ b/src/mesa/shader/prog_statevars.h @@ -129,7 +129,7 @@ extern GLbitfield _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]); -extern const char * +extern char * _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]); -- cgit v1.2.3