diff options
author | Chia-I Wu <[email protected]> | 2010-12-06 14:38:23 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-12-06 15:40:37 +0800 |
commit | 5ae4b6693a8254236435960ef84701fe405fe59b (patch) | |
tree | d42b857ee61de76f8b12f5d71c61f6e738977d4e /src/gallium/state_trackers | |
parent | 2b1469340bbf910469449354eeb5c02a9acfedba (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/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/egl/common/egl_g3d_api.c | 15 |
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 f505220222e..8e53e1dccba 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; |