summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2017-01-13 11:12:51 +0000
committerJose Fonseca <jfonseca@vmware.com>2017-01-18 13:28:50 +0000
commit0eb5bef639c0d792ef3595f38feaa023417216f9 (patch)
tree224c00e33155a18d51fa7a8af89c156939e51af5
parent75fc32edfdbf7240a7458ef5cc761bc0bc063eea (diff)
downloadmesa-demos-0eb5bef639c0d792ef3595f38feaa023417216f9.zip
mesa-demos-0eb5bef639c0d792ef3595f38feaa023417216f9.tar.xz
texdown: Use alligned_alloc/_aligned_malloc.
Simplifies the code and addresses compiler warnings.
-rw-r--r--src/tests/texdown.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/tests/texdown.c b/src/tests/texdown.c
index 64b6ae6..a06988e 100644
--- a/src/tests/texdown.c
+++ b/src/tests/texdown.c
@@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <malloc.h>
#include <math.h>
#include <GL/glew.h>
#include "glut_wrap.h"
@@ -162,7 +163,6 @@ MeasureDownloadRate(void)
const int h = TexHeight + 2 * TexBorder;
const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
const int bytes = image_bytes * NR_TEXOBJ;
- GLubyte *orig_texImage, *orig_getImage;
GLubyte *texImage;
GLdouble t0, t1, time;
int count;
@@ -173,18 +173,17 @@ MeasureDownloadRate(void)
printf("allocating %d bytes for %d %dx%d images\n",
bytes, NR_TEXOBJ, w, h);
- orig_texImage = (GLubyte *) malloc(bytes + ALIGN);
- orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
- if (!orig_texImage || !orig_getImage) {
+#ifdef _WIN32
+ texImage = (GLubyte *) _aligned_malloc(bytes, ALIGN);
+#else
+ texImage = (GLubyte *) aligned_alloc(ALIGN, bytes);
+#endif
+ if (!texImage) {
DownloadRate = 0.0;
- free(orig_texImage);
- free(orig_getImage);
return;
}
- printf("alloc %p %p\n", orig_texImage, orig_getImage);
-
- texImage = (GLubyte *)align((unsigned long)orig_texImage, ALIGN);
+ printf("alloc %p\n", texImage);
for (i = 1; !(((unsigned long)texImage) & i); i<<=1)
;
@@ -285,8 +284,11 @@ MeasureDownloadRate(void)
DownloadRate = total / time;
- free(orig_texImage);
- free(orig_getImage);
+#ifdef _WIN32
+ _aligned_free(texImage);
+#else
+ free(texImage);
+#endif
{
GLint err = glGetError();