diff options
author | David Robillard <d@drobilla.net> | 2012-05-11 22:34:48 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-11 22:34:48 +0000 |
commit | 53f8f81e2742876c8192b9429c4d4d20e9722b8b (patch) | |
tree | 667720fb6c5f8b1dba3a64b38eb1f030687b43a8 /pugl/pugl_x11.c | |
parent | c5cf34948acafc7ecb22e481fd513c62111bbc0f (diff) | |
download | pugl-53f8f81e2742876c8192b9429c4d4d20e9722b8b.tar.gz pugl-53f8f81e2742876c8192b9429c4d4d20e9722b8b.tar.bz2 pugl-53f8f81e2742876c8192b9429c4d4d20e9722b8b.zip |
Fix memory leaks.
Diffstat (limited to 'pugl/pugl_x11.c')
-rw-r--r-- | pugl/pugl_x11.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index dde2b23..f3debec 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -31,7 +31,7 @@ #include "pugl_internal.h" -struct PuglPlatformDataImpl { +struct PuglInternalsImpl { Display* display; int screen; Window win; @@ -72,12 +72,13 @@ puglCreate(PuglNativeWindow parent, int height, bool resizable) { - PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); - - view->impl = (PuglPlatformData*)calloc(1, sizeof(PuglPlatformData)); - - PuglPlatformData* impl = view->impl; + PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); + PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); + if (!view || !impl) { + return NULL; + } + view->impl = impl; view->width = width; view->height = height; @@ -85,7 +86,7 @@ puglCreate(PuglNativeWindow parent, impl->screen = DefaultScreen(impl->display); XVisualInfo* vi = glXChooseVisual(impl->display, impl->screen, attrListDbl); - if (vi == NULL) { + if (!vi) { vi = glXChooseVisual(impl->display, impl->screen, attrListSgl); impl->doubleBuffered = False; printf("singlebuffered rendering will be used, no doublebuffering available\n"); @@ -149,6 +150,8 @@ puglCreate(PuglNativeWindow parent, printf("no DRI available\n"); } + XFree(vi); + return view; } @@ -159,10 +162,10 @@ puglDestroy(PuglView* view) return; } - glXMakeCurrent(view->impl->display, None, NULL); glXDestroyContext(view->impl->display, view->impl->ctx); XDestroyWindow(view->impl->display, view->impl->win); XCloseDisplay(view->impl->display); + free(view->impl); free(view); } |