summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver McFadden <z3ro.geek@gmail.com>2007-03-15 19:49:10 +0000
committerOliver McFadden <z3ro.geek@gmail.com>2007-03-15 19:49:10 +0000
commit0e9ada1087a58af4c1375cc35b318aa0521d3a72 (patch)
treed82cd3732a34e3bd7a4ca36dc204ae112c56d7de
parent0d6d80ef3dbd39ed346c3189385242016f5aed74 (diff)
r300: Use _mesa_alloc_instructions/_mesa_init_instructions instead of malloc.
Note that insert_wpos in r300_vertexprog.c is still a little flaky and could be improved.
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c10
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertexprog.c15
2 files changed, 11 insertions, 14 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index 82fb5b66ed..e05abdb7c6 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -1798,12 +1798,8 @@ static void insert_wpos(struct gl_program *prog)
/* should do something else if no temps left... */
prog->NumTemporaries++;
-
- fpi = malloc((prog->NumInstructions + 3) * sizeof(struct prog_instruction));
- /* all including END */
- memcpy(&fpi[3], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
-
- memset(fpi, 0, 3 * sizeof(struct prog_instruction));
+ fpi = _mesa_alloc_instructions (prog->NumInstructions + 3);
+ _mesa_init_instructions (fpi, prog->NumInstructions + 3);
/* perspective divide */
fpi[i].Opcode = OPCODE_RCP;
@@ -1857,6 +1853,8 @@ static void insert_wpos(struct gl_program *prog)
fpi[i].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
i++;
+ _mesa_memcpy(&fpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
+
free(prog->Instructions);
prog->Instructions = fpi;
diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c
index 9257ff44e3..0c43270d75 100644
--- a/src/mesa/drivers/dri/r300/r300_vertexprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c
@@ -889,8 +889,8 @@ static void position_invariant(struct gl_program *prog)
#endif
paramList = prog->Parameters;
- vpi = malloc((prog->NumInstructions + 4) * sizeof(struct prog_instruction));
- memset(vpi, 0, 4 * sizeof(struct prog_instruction));
+ vpi = _mesa_alloc_instructions (prog->NumInstructions + 4);
+ _mesa_init_instructions (vpi, prog->NumInstructions + 4);
for (i=0; i < 4; i++) {
GLint idx;
@@ -946,7 +946,7 @@ static void position_invariant(struct gl_program *prog)
#endif
}
- memcpy(&vpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
+ _mesa_memcpy(&vpi[i], prog->Instructions, prog->NumInstructions * sizeof(struct prog_instruction));
free(prog->Instructions);
@@ -966,15 +966,14 @@ static void insert_wpos(struct r300_vertex_program *vp,
struct prog_instruction *vpi_insert;
int i = 0;
- vpi = malloc((prog->NumInstructions + 2) * sizeof(struct prog_instruction));
+ vpi = _mesa_alloc_instructions (prog->NumInstructions + 2);
+ _mesa_init_instructions (vpi, prog->NumInstructions + 2);
/* all but END */
- memcpy(vpi, prog->Instructions, (prog->NumInstructions - 1) * sizeof(struct prog_instruction));
+ _mesa_memcpy(vpi, prog->Instructions, (prog->NumInstructions - 1) * sizeof(struct prog_instruction));
/* END */
- memcpy(&vpi[prog->NumInstructions + 1], &prog->Instructions[prog->NumInstructions - 1],
+ _mesa_memcpy(&vpi[prog->NumInstructions + 1], &prog->Instructions[prog->NumInstructions - 1],
sizeof(struct prog_instruction));
-
vpi_insert = &vpi[prog->NumInstructions - 1];
- memset(vpi_insert, 0, 2 * sizeof(struct prog_instruction));
vpi_insert[i].Opcode = OPCODE_MOV;