[Piglit] [PATCH] textureGather: Avoid variable length arrays.

Brian Paul brianp at vmware.com
Mon Apr 28 07:14:55 PDT 2014


On 04/28/2014 08:12 AM, jfonseca at vmware.com wrote:
> From: José Fonseca <jfonseca at vmware.com>
>
> Not supported by MSVC.
> ---
>   tests/texturing/shaders/textureGather.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tests/texturing/shaders/textureGather.c b/tests/texturing/shaders/textureGather.c
> index cb7fef0..bd48790 100644
> --- a/tests/texturing/shaders/textureGather.c
> +++ b/tests/texturing/shaders/textureGather.c
> @@ -201,7 +201,9 @@ static void
>   upload_verts(void)
>   {
>   	if (stage == VS) {
> -		float v[4 * texture_width * texture_height], *pv = v;
> +		size_t size = 4 * texture_width * texture_height * sizeof(float);
> +		float *v = (float *)malloc(size);
> +		float *pv = v;
>   		int i, j;
>   		for (j = 0; j < texture_height; j++)
>   			for (i = 0; i < texture_width; i++) {
> @@ -210,7 +212,8 @@ upload_verts(void)
>   				*pv++ = 0;
>   				*pv++ = 1;
>   			}
> -		glBufferData(GL_ARRAY_BUFFER, sizeof(v), v, GL_STATIC_DRAW);
> +		glBufferData(GL_ARRAY_BUFFER, size, v, GL_STATIC_DRAW);
> +		free(v);
>   	}
>   	else {
>   		static const float verts[] = {
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the Piglit mailing list