summaryrefslogtreecommitdiff
path: root/src/egl/main/eglconfig.c
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/egl/main/eglconfig.c
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/egl/main/eglconfig.c')
-rw-r--r--src/egl/main/eglconfig.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index fec94fb20c..5b377b7f61 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -697,11 +697,22 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list,
if (!_eglParseConfigAttribList(&criteria, disp, attrib_list))
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
- configList = (_EGLConfig **) _eglFilterArray(disp->Configs, &count,
+ /* get the number of matched configs */
+ count = _eglFilterArray(disp->Configs, NULL, 0,
(_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
+ if (!count) {
+ *num_configs = count;
+ return EGL_TRUE;
+ }
+
+ configList = malloc(sizeof(*configList) * count);
if (!configList)
return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)");
+ /* get the matched configs */
+ _eglFilterArray(disp->Configs, (void **) configList, count,
+ (_EGLArrayForEach) _eglMatchConfig, (void *) &criteria);
+
/* perform sorting of configs */
if (configs && count) {
_eglSortConfigs((const _EGLConfig **) configList, count,