Hi -
I've discovered that the finalizer in the code below is always called with a NULL pointer even though the pointer returned by the allocation routine is always not NULL.
Is this a known bug, and if so, are there any workarounds?
I'm using ghc version 6.4:

data RawFont
newtype Font = Font (ForeignPtr RawFont)

foreign import ccall duma_createFont ::
   CString -> Int -> Bool -> Bool -> Bool -> IO (Ptr RawFont)
foreign import ccall duma_releaseFont ::
   FunPtr (Ptr RawFont -> IO ())

createFont :: String -> Int -> Bool -> Bool -> Bool -> IO Font
createFont name pointSize bold italic underline = block $ do
  f <- (withCString name $ \cname ->
          duma_createFont cname pointSize
               bold italic underline) >>=
       newForeignPtr duma_releaseFont -- Gets a NULL pointer!!!
  return $ Font f

Thanks, Brian.
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to