Re: [waffle] [PATCH 03/33] cgl: avoid leaking the PixelFormat

2014-07-15 Thread Chad Versace
Patches 1-3 look good and are committed to master.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 03/33] cgl: avoid leaking the PixelFormat

2014-07-07 Thread Emil Velikov
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.veli...@gmail.com
---
 src/waffle/cgl/cgl_config.m | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/waffle/cgl/cgl_config.m b/src/waffle/cgl/cgl_config.m
index 7a74438..5252e12 100644
--- a/src/waffle/cgl/cgl_config.m
+++ b/src/waffle/cgl/cgl_config.m
@@ -50,6 +50,9 @@ cgl_config_destroy(struct wcore_config *wc_self)
 if (wc_self == NULL)
 return ok;
 
+if (self-pixel_format)
+CGLReleasePixelFormat(self-pixel_format);
+
 ok = wcore_config_teardown(wc_self);
 free(cgl_config(wc_self));
 return ok;
@@ -248,6 +251,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);
-- 
2.0.0

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle