aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
committermarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
commitccc8a492607df715b08d27c6bb3b9d13b1ff48a2 (patch)
tree4311d252acd49786ceed60cb55343af0a9294a2f /mesalib/src/mesa/program
parenta4d007b9b60f2fc7c8de46533e2f47ecb24f3c9c (diff)
parentaa10a08696cae93799fcddae3f0245ceee905e01 (diff)
downloadvcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.gz
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.bz2
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/program')
-rw-r--r--mesalib/src/mesa/program/arbprogparse.c12
-rw-r--r--mesalib/src/mesa/program/nvfragparse.c12
-rw-r--r--mesalib/src/mesa/program/nvvertparse.c12
-rw-r--r--mesalib/src/mesa/program/prog_cache.c4
-rw-r--r--mesalib/src/mesa/program/prog_instruction.c8
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c6
-rw-r--r--mesalib/src/mesa/program/prog_parameter.c3
-rw-r--r--mesalib/src/mesa/program/program.c5
8 files changed, 23 insertions, 39 deletions
diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c
index 72e51dd0f..527bb936e 100644
--- a/mesalib/src/mesa/program/arbprogparse.c
+++ b/mesalib/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/mesalib/src/mesa/program/nvfragparse.c b/mesalib/src/mesa/program/nvfragparse.c
index f61221c11..f251d7e6c 100644
--- a/mesalib/src/mesa/program/nvfragparse.c
+++ b/mesalib/src/mesa/program/nvfragparse.c
@@ -1236,7 +1236,7 @@ Parse_PrintInstruction(struct parse_state *parseState,
for (len = 0; str[len] != '\''; len++) /* find closing quote */
;
parseState->pos += len + 1;
- msg = (GLubyte*) malloc(len + 1);
+ msg = malloc(len + 1);
memcpy(msg, str, len);
msg[len] = 0;
@@ -1481,7 +1481,7 @@ _mesa_parse_nv_fragment_program(struct gl_context *ctx, GLenum dstTarget,
GLubyte *programString;
/* Make a null-terminated copy of the program string */
- programString = (GLubyte *) malloc(len + 1);
+ programString = malloc(len + 1);
if (!programString) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -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/mesalib/src/mesa/program/nvvertparse.c b/mesalib/src/mesa/program/nvvertparse.c
index 62b27b9f4..6272c2f7f 100644
--- a/mesalib/src/mesa/program/nvvertparse.c
+++ b/mesalib/src/mesa/program/nvvertparse.c
@@ -1050,7 +1050,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction *
for (len = 0; str[len] != '\''; len++) /* find closing quote */
;
parseState->pos += len + 1;
- msg = (GLubyte*) malloc(len + 1);
+ msg = malloc(len + 1);
memcpy(msg, str, len);
msg[len] = 0;
@@ -1293,7 +1293,7 @@ _mesa_parse_nv_vertex_program(struct gl_context *ctx, GLenum dstTarget,
GLubyte *programString;
/* Make a null-terminated copy of the program string */
- programString = (GLubyte *) malloc(len + 1);
+ programString = malloc(len + 1);
if (!programString) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
return;
@@ -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/mesalib/src/mesa/program/prog_cache.c b/mesalib/src/mesa/program/prog_cache.c
index 2ccedb5d7..47f926b1b 100644
--- a/mesalib/src/mesa/program/prog_cache.c
+++ b/mesalib/src/mesa/program/prog_cache.c
@@ -88,7 +88,7 @@ rehash(struct gl_program_cache *cache)
cache->last = NULL;
size = cache->size * 3;
- items = (struct cache_item**) malloc(size * sizeof(*items));
+ items = malloc(size * sizeof(*items));
memset(items, 0, size * sizeof(*items));
for (i = 0; i < cache->size; i++)
@@ -141,7 +141,7 @@ _mesa_new_program_cache(void)
struct gl_program_cache *cache = CALLOC_STRUCT(gl_program_cache);
if (cache) {
cache->size = 17;
- cache->items = (struct cache_item **)
+ cache->items =
calloc(1, cache->size * sizeof(struct cache_item));
if (!cache->items) {
free(cache);
diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index 5d6cb476c..d69d7b2d4 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -69,7 +69,7 @@ _mesa_init_instructions(struct prog_instruction *inst, GLuint count)
struct prog_instruction *
_mesa_alloc_instructions(GLuint numInst)
{
- return (struct prog_instruction *)
+ return
calloc(1, numInst * sizeof(struct prog_instruction));
}
@@ -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/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 25d9684b1..e89e8d6a4 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -260,7 +260,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog)
/*_mesa_print_program(prog);*/
}
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
/* Determine which temps are read and written */
@@ -604,7 +604,7 @@ _mesa_remove_dead_code_local(struct gl_program *prog)
GLboolean *removeInst;
GLuint i, arg, rem = 0;
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
for (i = 0; i < prog->NumInstructions; i++) {
@@ -745,7 +745,7 @@ _mesa_remove_extra_moves(struct gl_program *prog)
_mesa_print_program(prog);
}
- removeInst = (GLboolean *)
+ removeInst =
calloc(1, prog->NumInstructions * sizeof(GLboolean));
/*
diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c
index 2018fa520..b9f4d9d57 100644
--- a/mesalib/src/mesa/program/prog_parameter.c
+++ b/mesalib/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/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 15337f4d8..becb77c1d 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -249,7 +249,7 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
while (*p != 0 && *p != '\n')
p++;
len = p - lineStart;
- s = (GLubyte *) malloc(len + 1);
+ s = malloc(len + 1);
memcpy(s, lineStart, len);
s[len] = 0;
@@ -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);