From 53f8f81e2742876c8192b9429c4d4d20e9722b8b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 May 2012 22:34:48 +0000 Subject: Fix memory leaks. --- pugl/pugl_win.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pugl/pugl_win.cpp') diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp index cc69036..63d484f 100644 --- a/pugl/pugl_win.cpp +++ b/pugl/pugl_win.cpp @@ -24,7 +24,7 @@ #include "pugl_internal.h" -struct PuglPlatformDataImpl { +struct PuglInternalsImpl { HWND hwnd; HDC hdc; HGLRC hglrc; @@ -58,11 +58,15 @@ puglCreate(PuglNativeWindow parent, int height, bool resizable) { - PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); - - view->impl = (PuglPlatformData*)calloc(1, sizeof(PuglPlatformData)); + PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); + PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); + if (!view || !impl) { + return NULL; + } - PuglPlatformData* impl = view->impl; + view->impl = impl; + view->width = width; + view->height = height; WNDCLASS wc; wc.style = CS_OWNDC; @@ -113,6 +117,7 @@ puglDestroy(PuglView* view) wglDeleteContext(view->impl->hglrc); ReleaseDC(view->impl->hwnd, view->impl->hdc); DestroyWindow(view->impl->hwnd); + free(view->impl); free(view); } -- cgit v1.2.3