From 9899f58c76d3eaab940b4e2e33d722ac4721ea13 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 8 Jun 2005 21:57:45 +0000 Subject: Use ALIGN_MALLOC for parameter lists. --- src/mesa/shader/program.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/mesa/shader/program.c') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 1e2d34a3079..0ccc741dd0c 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -353,7 +353,8 @@ _mesa_free_parameter_list(struct program_parameter_list *paramList) { _mesa_free_parameters(paramList); _mesa_free(paramList->Parameters); - _mesa_free(paramList->ParameterValues); + if (paramList->ParameterValues) + ALIGN_FREE(paramList->ParameterValues); _mesa_free(paramList); } @@ -385,18 +386,24 @@ add_parameter(struct program_parameter_list *paramList, const GLuint n = paramList->NumParameters; if (n == paramList->Size) { + GLfloat (*tmp)[4]; + paramList->Size *= 2; if (!paramList->Size) - paramList->Size = 4; + paramList->Size = 8; paramList->Parameters = (struct program_parameter *) _mesa_realloc(paramList->Parameters, n * sizeof(struct program_parameter), paramList->Size * sizeof(struct program_parameter)); - paramList->ParameterValues = (GLfloat (*)[4]) - _mesa_realloc(paramList->ParameterValues, - n * 4 * sizeof(GLfloat), - paramList->Size * 4 * sizeof(GLfloat)); + + tmp = paramList->ParameterValues; + paramList->ParameterValues = ALIGN_MALLOC(paramList->Size * 4 * sizeof(GLfloat), 16); + if (tmp) { + _mesa_memcpy(paramList->ParameterValues, tmp, + n * 4 * sizeof(GLfloat)); + ALIGN_FREE(tmp); + } } if (!paramList->Parameters || -- cgit v1.2.3