summaryrefslogtreecommitdiffstats
path: root/Bindings/GLX.chs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-02-22 18:42:09 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-02-22 18:42:09 +0100
commit8f693405d6a0237125836b15c0742bbba9945b5e (patch)
treed7614ef89e09f5a1acf7e9fe57d4d59977d48ac3 /Bindings/GLX.chs
parent465bf683453c869e9b81c87661540c5e28438b1c (diff)
downloadhtanks-8f693405d6a0237125836b15c0742bbba9945b5e.tar
htanks-8f693405d6a0237125836b15c0742bbba9945b5e.zip
Free foreign pointers
Diffstat (limited to 'Bindings/GLX.chs')
-rw-r--r--Bindings/GLX.chs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Bindings/GLX.chs b/Bindings/GLX.chs
index dcf235e..58bc8cf 100644
--- a/Bindings/GLX.chs
+++ b/Bindings/GLX.chs
@@ -7,7 +7,6 @@ module Bindings.GLX ( createColormap
, VisualInfo(..)
, SetWindowAttributes(..)
, nullSetWindowAttributes
- , getVisualFromFBConfig
, renderType
, rgbaBit
, drawableType
@@ -16,7 +15,6 @@ module Bindings.GLX ( createColormap
, doublebuffer
, depthSize
, stencilSize
- , true
, createContext
, makeCurrent
, Context(..)
@@ -27,13 +25,14 @@ import Data.Int
import Data.Word
import Foreign.C.Types
+import Foreign.ForeignPtr
import Foreign.Ptr
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray, withArray0)
import Foreign.Storable
import Graphics.X11.Types (AttributeMask, Colormap, ColormapAlloc, Cursor, EventMask, Pixmap, Window, WindowClass, VisualID, XID)
-import Graphics.X11.Xlib.Extras (none)
+import Graphics.X11.Xlib.Extras (none, xFree)
import Graphics.X11.Xlib.Types (Dimension, Display, Pixel, Position)
@@ -198,7 +197,10 @@ chooseFBConfig :: Display -> CInt -> [(CInt, CInt)] -> IO [FBConfig]
chooseFBConfig disp sc attr = alloca $ \n -> withArray0 (fromIntegral none) (concatMap (\(a,b) -> [a,b]) attr) $ \attrp -> do
configs <- glXChooseFBConfig disp sc attrp n
nelements <- peek n
- peekArray (fromIntegral nelements) configs
+ configlist <- peekArray (fromIntegral nelements) configs
+ xFree configs
+ return configlist
+
renderType :: CInt
renderType = (#const GLX_RENDER_TYPE)
@@ -224,16 +226,15 @@ depthSize = (#const GLX_DEPTH_SIZE)
stencilSize :: CInt
stencilSize = (#const GLX_STENCIL_SIZE)
-true :: CInt
-true = (#const True)
-
foreign import ccall unsafe "GL/glx.h glXGetVisualFromFBConfig"
glXGetVisualFromFBConfig :: Display -> FBConfig -> IO (Ptr VisualInfo)
getVisualFromFBConfig :: Display -> FBConfig -> IO (VisualInfo)
getVisualFromFBConfig disp config = do
- vi <- glXGetVisualFromFBConfig disp config
- peek vi
+ viptr <- glXGetVisualFromFBConfig disp config
+ vi <- peek viptr
+ xFree viptr
+ return vi
foreign import ccall unsafe "GL/glx.h glXCreateContext"
createContext :: Display -> Ptr VisualInfo -> Context -> Bool -> IO Context