Commits

Bryan O'Sullivan committed 4594928

Tidy up Dan's patch.

Comments (0)

Files changed (1)

Network/Pcap/Base.hsc

 import Foreign.Ptr (Ptr, plusPtr, nullPtr, FunPtr, freeHaskellFunPtr)
 import Foreign.C.String (CString, peekCString, withCString)
 import Foreign.C.Types (CInt, CUInt, CChar, CUChar, CLong)
-import Foreign.Concurrent (addForeignPtrFinalizer, newForeignPtr)
-import Foreign.ForeignPtr (ForeignPtr,FinalizerPtr)
+import Foreign.Concurrent (newForeignPtr)
+import Foreign.ForeignPtr (ForeignPtr)
 import Foreign.Marshal.Alloc (alloca, allocaBytes, free)
 import Foreign.Marshal.Array (allocaArray, peekArray)
 import Foreign.Marshal.Utils (fromBool, toBool)
 openOffline name =
     withCString name $ \namePtr -> do
       ptr <- withErrBuf (== nullPtr) (pcap_open_offline namePtr)
---      final <- h2c pcap_close
       newForeignPtr ptr (pcap_close ptr)
 
 -- | 'openLive' is used to get a packet descriptor that can be used to
     withCString name $ \namePtr -> do
       ptr <- withErrBuf (== nullPtr) $ pcap_open_live namePtr
              (fromIntegral snaplen) (fromBool promisc) (fromIntegral timeout)
---      final <- h2c pcap_close
---      newForeignPtr final ptr
       newForeignPtr ptr (pcap_close ptr)
 
 -- | 'openDead' is used to get a packet capture descriptor without
     when (ptr == nullPtr) $
         ioError $ userError "Can't open dead pcap device"
     newForeignPtr ptr (pcap_close ptr)
---    final <- h2c pcap_close
---    newForeignPtr final ptr
 
 
 foreign import ccall unsafe pcap_open_offline
     :: CString -> CInt -> CInt -> CInt -> ErrBuf -> IO (Ptr PcapTag)
 foreign import ccall unsafe pcap_open_dead
     :: CInt -> CInt -> IO (Ptr PcapTag)
-foreign import ccall "wrapper" h2c
-    :: (Ptr PcapTag -> IO()) -> IO (FinalizerPtr a)
 
 
 --
     withCString name $ \namePtr -> do
       ptr <- pcap_dump_open hdl namePtr >>= throwPcapIf hdl (== nullPtr)
       newForeignPtr ptr (pcap_dump_close ptr)
---      final <- h2c' pcap_dump_close
---      newForeignPtr final ptr
 
 foreign import ccall unsafe pcap_dump_open
     :: Ptr PcapTag -> CString -> IO (Ptr PcapDumpTag)
 foreign import ccall unsafe pcap_dump_close
     :: Ptr PcapDumpTag -> IO ()
-foreign import ccall "wrapper" h2c'
-    :: (Ptr PcapDumpTag -> IO()) -> IO (FinalizerPtr a)
 
 --
 -- Set the filter
 	when (ret == (-1)) $
 	    ioError $ userError "Pcap.compileFilter error"
         newForeignPtr bpfp (pcap_freecode bpfp)
---        final <- h2c'' pcap_freecode
---        newForeignPtr final bpfp
 
 foreign import ccall pcap_compile
 	:: Ptr PcapTag  -> Ptr BpfProgramTag -> CString -> CInt -> CInt
 	:: Ptr PcapTag  -> Ptr BpfProgramTag -> IO CInt
 foreign import ccall pcap_freecode
 	:: Ptr BpfProgramTag -> IO ()
-foreign import ccall "wrapper" h2c''
-	:: (Ptr BpfProgramTag -> IO ()) -> IO (FinalizerPtr a)
 
 --
 -- Find devices