summaryrefslogtreecommitdiff
path: root/pugl/pugl_win.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-11 22:34:48 +0000
committerDavid Robillard <d@drobilla.net>2012-05-11 22:34:48 +0000
commit53f8f81e2742876c8192b9429c4d4d20e9722b8b (patch)
tree667720fb6c5f8b1dba3a64b38eb1f030687b43a8 /pugl/pugl_win.cpp
parentc5cf34948acafc7ecb22e481fd513c62111bbc0f (diff)
Fix memory leaks.
Diffstat (limited to 'pugl/pugl_win.cpp')
-rw-r--r--pugl/pugl_win.cpp15
1 files changed, 10 insertions, 5 deletions
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);
}