diff options
author | Matt Turner <[email protected]> | 2012-09-03 20:24:35 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2012-09-05 22:28:50 -0700 |
commit | 5067506ea6ada5eeae33b1acf1c916e00121c12a (patch) | |
tree | a6b4ff2e3cf5fb6058101aee3b6f1dcd3f382c15 /src/mesa/program | |
parent | a9e8054fffc6e3e6a5f108a96c331858c28a5862 (diff) |
Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic
patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it
@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free(E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
type T;
@@
+ free ((T) E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free((T) E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
- free (E);
- }
@@
expression E;
type T;
@@
+ free ((T) E);
- if (unlikely (E != NULL)) {
- free ((T) E);
- }
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/program')
-rw-r--r-- | src/mesa/program/arbprogparse.c | 12 | ||||
-rw-r--r-- | src/mesa/program/nvfragparse.c | 8 | ||||
-rw-r--r-- | src/mesa/program/nvvertparse.c | 8 | ||||
-rw-r--r-- | src/mesa/program/prog_instruction.c | 6 | ||||
-rw-r--r-- | src/mesa/program/prog_parameter.c | 3 | ||||
-rw-r--r-- | src/mesa/program/program.c | 3 |
6 files changed, 12 insertions, 28 deletions
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c index 72e51dd0ffe..527bb936ec8 100644 --- a/src/mesa/program/arbprogparse.c +++ b/src/mesa/program/arbprogparse.c @@ -84,8 +84,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, return; } - if (program->Base.String != NULL) - free(program->Base.String); + free(program->Base.String); /* Copy the relevant contents of the arb_program struct into the * fragment_program struct. @@ -122,8 +121,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, program->UsesKill = state.fragment.UsesKill; program->UsesDFdy = state.fragment.UsesDFdy; - if (program->Base.Instructions) - free(program->Base.Instructions); + free(program->Base.Instructions); program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) @@ -179,8 +177,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, return; } - if (program->Base.String != NULL) - free(program->Base.String); + free(program->Base.String); /* Copy the relevant contents of the arb_program struct into the * vertex_program struct. @@ -202,8 +199,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, program->IsPositionInvariant = (state.option.PositionInvariant) ? GL_TRUE : GL_FALSE; - if (program->Base.Instructions) - free(program->Base.Instructions); + free(program->Base.Instructions); program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) diff --git a/src/mesa/program/nvfragparse.c b/src/mesa/program/nvfragparse.c index ab69a04fcf0..f251d7e6c9a 100644 --- a/src/mesa/program/nvfragparse.c +++ b/src/mesa/program/nvfragparse.c @@ -1549,14 +1549,10 @@ _mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget, /* install the program */ program->Base.Target = target; - if (program->Base.String) { - free(program->Base.String); - } + free(program->Base.String); program->Base.String = programString; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; - if (program->Base.Instructions) { - free(program->Base.Instructions); - } + free(program->Base.Instructions); program->Base.Instructions = newInst; program->Base.NumInstructions = parseState.numInst; program->Base.InputsRead = parseState.inputsRead; diff --git a/src/mesa/program/nvvertparse.c b/src/mesa/program/nvvertparse.c index b33056a3990..6272c2f7fee 100644 --- a/src/mesa/program/nvvertparse.c +++ b/src/mesa/program/nvvertparse.c @@ -1382,14 +1382,10 @@ _mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget, /* install the program */ program->Base.Target = target; - if (program->Base.String) { - free(program->Base.String); - } + free(program->Base.String); program->Base.String = programString; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; - if (program->Base.Instructions) { - free(program->Base.Instructions); - } + free(program->Base.Instructions); program->Base.Instructions = newInst; program->Base.InputsRead = parseState.inputsRead; if (parseState.isPositionInvariant) diff --git a/src/mesa/program/prog_instruction.c b/src/mesa/program/prog_instruction.c index f9a33d4effe..d69d7b2d465 100644 --- a/src/mesa/program/prog_instruction.c +++ b/src/mesa/program/prog_instruction.c @@ -127,10 +127,8 @@ _mesa_free_instructions(struct prog_instruction *inst, GLuint count) { GLuint i; for (i = 0; i < count; i++) { - if (inst[i].Data) - free(inst[i].Data); - if (inst[i].Comment) - free((char *) inst[i].Comment); + free(inst[i].Data); + free((char *)inst[i].Comment); } free(inst); } diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 2018fa52071..b9f4d9d572a 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -80,8 +80,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList) { GLuint i; for (i = 0; i < paramList->NumParameters; i++) { - if (paramList->Parameters[i].Name) - free((void *) paramList->Parameters[i].Name); + free((void *)paramList->Parameters[i].Name); } free(paramList->Parameters); if (paramList->ParameterValues) diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 7c1d2f7741f..becb77c1d60 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -382,8 +382,7 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) if (prog == &_mesa_DummyProgram) return; - if (prog->String) - free(prog->String); + free(prog->String); if (prog->Instructions) { _mesa_free_instructions(prog->Instructions, prog->NumInstructions); |