summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-12-06 14:38:23 +0800
committerChia-I Wu <olv@lunarg.com>2010-12-06 15:40:37 +0800
commit5ae4b6693a8254236435960ef84701fe405fe59b (patch)
treed42b857ee61de76f8b12f5d71c61f6e738977d4e /src/gallium
parent2b1469340bbf910469449354eeb5c02a9acfedba (diff)
egl: _eglFilterArray should not allocate.
Otherwise, when it is called from within a driver, the caller cannot free the returned data (on Windows).
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_api.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
index f505220222..8e53e1dccb 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
@@ -141,11 +141,22 @@ egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
if (!_eglParseConfigAttribList(&criteria, dpy, attribs))
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
- tmp_configs = (_EGLConfig **) _eglFilterArray(dpy->Configs, &tmp_size,
+ /* get the number of matched configs */
+ tmp_size = _eglFilterArray(dpy->Configs, NULL, 0,
(_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
+ if (!tmp_size) {
+ *num_configs = tmp_size;
+ return EGL_TRUE;
+ }
+
+ tmp_configs = MALLOC(sizeof(tmp_configs[0]) * tmp_size);
if (!tmp_configs)
return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
+ /* get the matched configs */
+ _eglFilterArray(dpy->Configs, (void **) tmp_configs, tmp_size,
+ (_EGLArrayForEach) egl_g3d_match_config, (void *) &criteria);
+
/* perform sorting of configs */
if (tmp_configs && tmp_size) {
_eglSortConfigs((const _EGLConfig **) tmp_configs, tmp_size,
@@ -155,7 +166,7 @@ egl_g3d_choose_config(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attribs,
configs[i] = _eglGetConfigHandle(tmp_configs[i]);
}
- free(tmp_configs);
+ FREE(tmp_configs);
*num_configs = size;