KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Here's my situation: I would like to call ffmpeg's av_free_packet function: // avformat.h static inline void av_free_packet(AVPacket *pkt) { if (pkt && pkt->destruct) pkt->destruct(pkt); } But unfortunately this function is static inline , and so doesn't really appear in the linked library. However, it is a very simple function, which I could reimplement in Haskell. And that's what I can't figure out how to do. Here's a partial attempt (.hsc): av_free_packet :: Ptr AVPacket -> IO () av_free_packet pkt = when (nullPtr /= pkt) $ do destruct <- (#peek AVPacket, destruct) pkt :: IO (FunPtr (Ptr AVPacket -> IO ())) when (nullFunPtr /= destruct) $ funPtrToFun destruct pkt funPtrToFun :: FunPtr a -> a funPtrToFun = ? For now I could resort to implementing this function in C (by just calling the original), but it seems to me that calling function pointers should be possible somehow..
Tags (comma-separated)
Save Edits
Cancel