[Piglit] [PATCH 3/4] rg-teximage: remove large stack allocations

Brian Paul brianp at vmware.com
Mon Mar 18 17:19:07 PDT 2013


Don't allocate 1MB arrays on the stack.  Use heap allocations instead.
---
 tests/texturing/rg-teximage-01.c   |    5 ++++-
 tests/texturing/rg-teximage-02.c   |    5 ++++-
 tests/texturing/rgtc-teximage-01.c |    5 ++++-
 tests/texturing/rgtc-teximage-02.c |    5 ++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/tests/texturing/rg-teximage-01.c b/tests/texturing/rg-teximage-01.c
index 815d8da..07f46a5 100644
--- a/tests/texturing/rg-teximage-01.c
+++ b/tests/texturing/rg-teximage-01.c
@@ -64,10 +64,11 @@ void
 piglit_init(int argc, char **argv)
 {
 	unsigned i;
-	GLfloat result[4 * WIDTH * HEIGHT];
+	GLfloat *result;
 
 	piglit_require_extension("GL_ARB_texture_rg");
 
+	result = (GLfloat *) malloc(4 * WIDTH * HEIGHT * sizeof(GLfloat));
 	generate_rainbow_texture_data(WIDTH, HEIGHT, rgba_image);
 
 	glEnable(GL_TEXTURE_2D);
@@ -103,6 +104,8 @@ piglit_init(int argc, char **argv)
 		}
 	}
 
+	free(result);
+
 	if (piglit_automatic)
 		piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
diff --git a/tests/texturing/rg-teximage-02.c b/tests/texturing/rg-teximage-02.c
index bcd5e53..776ed19 100644
--- a/tests/texturing/rg-teximage-02.c
+++ b/tests/texturing/rg-teximage-02.c
@@ -64,10 +64,11 @@ void
 piglit_init(int argc, char **argv)
 {
 	unsigned i;
-	GLfloat result[4 * WIDTH * HEIGHT];
+	GLfloat *result;
 
 	piglit_require_extension("GL_ARB_texture_rg");
 
+	result = (GLfloat *) malloc(4 * WIDTH * HEIGHT * sizeof(GLfloat));
 	generate_rainbow_texture_data(WIDTH, HEIGHT, rgba_image);
 
 	glEnable(GL_TEXTURE_2D);
@@ -103,6 +104,8 @@ piglit_init(int argc, char **argv)
 		}
 	}
 
+	free(result);
+
 	if (piglit_automatic)
 		piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
diff --git a/tests/texturing/rgtc-teximage-01.c b/tests/texturing/rgtc-teximage-01.c
index 0a17fb1..12bd35f 100644
--- a/tests/texturing/rgtc-teximage-01.c
+++ b/tests/texturing/rgtc-teximage-01.c
@@ -65,10 +65,11 @@ void
 piglit_init(int argc, char **argv)
 {
 	unsigned i;
-	GLfloat result[4 * WIDTH * HEIGHT];
+	GLfloat *result;
 
 	piglit_require_extension("GL_ARB_texture_compression_rgtc");
 
+	result = (GLfloat *) malloc(4 * WIDTH * HEIGHT * sizeof(GLfloat));
 	generate_rainbow_texture_data(WIDTH, HEIGHT, rgba_image);
 
 	glEnable(GL_TEXTURE_2D);
@@ -104,6 +105,8 @@ piglit_init(int argc, char **argv)
 		}
 	}
 
+	free(result);
+
 	if (piglit_automatic)
 		piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
diff --git a/tests/texturing/rgtc-teximage-02.c b/tests/texturing/rgtc-teximage-02.c
index f4cd4ed..945b999 100644
--- a/tests/texturing/rgtc-teximage-02.c
+++ b/tests/texturing/rgtc-teximage-02.c
@@ -65,10 +65,11 @@ void
 piglit_init(int argc, char **argv)
 {
 	unsigned i;
-	GLfloat result[4 * WIDTH * HEIGHT];
+	GLfloat *result;
 
 	piglit_require_extension("GL_ARB_texture_compression_rgtc");
 
+	result = (GLfloat *) malloc(4 * WIDTH * HEIGHT * sizeof(GLfloat));
 	generate_rainbow_texture_data(WIDTH, HEIGHT, rgba_image);
 
 	glEnable(GL_TEXTURE_2D);
@@ -104,6 +105,8 @@ piglit_init(int argc, char **argv)
 		}
 	}
 
+	free(result);
+
 	if (piglit_automatic)
 		piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
-- 
1.7.3.4



More information about the Piglit mailing list