From f347e2259f66ca2d43deaf8da7bd718622b90f9e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 28 Dec 2007 20:05:18 +0000 Subject: [PATCH] Plug some memory leaks --- source/display.cpp | 2 ++ source/glcontext.cpp | 8 ++++++++ source/glcontext.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/source/display.cpp b/source/display.cpp index b8e4fbe..ba5a640 100644 --- a/source/display.cpp +++ b/source/display.cpp @@ -73,6 +73,8 @@ Display::Display(const string &disp_name) modes.push_back(mode); } + XFree(infos); + XF86VidModeModeLine modeline; int dotclock; XF86VidModeGetModeLine(display, screen, &dotclock, &modeline); diff --git a/source/glcontext.cpp b/source/glcontext.cpp index 5995384..9377e88 100644 --- a/source/glcontext.cpp +++ b/source/glcontext.cpp @@ -65,9 +65,17 @@ GLContext::GLContext(Display &d, const GLOptions &opts): window=XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1024, 768, 0, vi->depth, InputOutput, vi->visual, CWColormap, &attr); + XFree(vi); + glXMakeCurrent(dpy, window, context); } +GLContext::~GLContext() +{ + glXDestroyContext(display.get_display(), context); + XDestroyWindow(display.get_display(), window); +} + void GLContext::attach(Window &wnd) { XReparentWindow(display.get_display(), window, wnd.get_handle(), 0, 0); diff --git a/source/glcontext.h b/source/glcontext.h index 1156b53..f9e5f46 100644 --- a/source/glcontext.h +++ b/source/glcontext.h @@ -38,6 +38,8 @@ private: public: GLContext(Display &dpy, const GLOptions &opts); + ~GLContext(); + void attach(Window &wnd); void swap_buffers(); private: -- 2.43.0