-- | Some internally used convenience functions. module Misc where import Foreign.C.Types import Foreign.ForeignPtr import Foreign.Storable import Foreign.Ptr mallocInitForeignPtr :: (Storable a) => (Ptr a -> IO ()) -> IO (ForeignPtr a) mallocInitForeignPtr initializer = mallocForeignPtr >>= \fptr -> withForeignPtr fptr initializer >> return fptr nullForeignPtr :: IO (ForeignPtr a) nullForeignPtr = newForeignPtr_ nullPtr cError :: CInt -> Bool cError = (== -1) cTrue :: CInt -> Bool cTrue 0 = False cTrue _ = True