diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2014-05-31 03:22:06 +0100 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2014-07-15 07:16:32 -0700 |
commit | 7b2be42a92899ff6f857758e57656285168ba791 (patch) | |
tree | 50ce2b7598f931cb7cbb3a0fe86905346cc96a37 | |
parent | 8853814f46d09fd37c9ef339650d7afc61a2523f (diff) | |
download | waffle-7b2be42a92899ff6f857758e57656285168ba791.tar.gz |
cgl: avoid leaking the PixelFormat
According to apple developer page, starting with OS X v10.5 the
pixelformat is reference counted. The object is created at
CGLChoosePixelFormat and should be unrefeferenced via
CGLReleasePixelFormat/CGLDestroyPixelFormat.
The latter two are identical accoring to the documentation.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | src/waffle/cgl/cgl_config.m | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/waffle/cgl/cgl_config.m b/src/waffle/cgl/cgl_config.m index 04688f4..d7e8ed3 100644 --- a/src/waffle/cgl/cgl_config.m +++ b/src/waffle/cgl/cgl_config.m @@ -45,13 +45,19 @@ bool cgl_config_destroy(struct wcore_config *wc_self) { + struct cgl_config *self; bool ok = true; if (wc_self == NULL) return ok; + self = cgl_config(wc_self); + + if (self->pixel_format) + CGLReleasePixelFormat(self->pixel_format); + ok &= wcore_config_teardown(wc_self); - free(cgl_config(wc_self)); + free(self); return ok; } @@ -248,6 +254,7 @@ cgl_config_choose(struct wcore_platform *wc_plat, if (!ok) goto error; + // Starting with OS X v10.5, pixel format objects are reference counted. error = CGLChoosePixelFormat(pixel_attrs, &self->pixel_format, &ignore); if (error) { cgl_error_failed_func("CGLChoosePixelFormat", error); |