From feca5c15c2c32ce30483f93aed6bbe91dcfd876a Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Thu, 2 Dec 2021 09:07:30 +0100 Subject: [PATCH] refactor(journal): remove unused functions and use unsafe ffi Unsafe ffi is apparently only unsafe if the C code calls Haskell, which shouldn't be happening in this case. --- src/journal/src/Journal/Internal.hs | 13 ------------- src/journal/test/Journal/CRC32Test.hs | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/journal/src/Journal/Internal.hs b/src/journal/src/Journal/Internal.hs index d1190f1c..6b17f890 100644 --- a/src/journal/src/Journal/Internal.hs +++ b/src/journal/src/Journal/Internal.hs @@ -123,19 +123,6 @@ readHeader ptr = do (decode (LBS.pack [b1])) (decode (LBS.pack [b2, b3, b4, b5]))) -headerExists :: Ptr Word8 -> Int -> IO Bool -headerExists ptr offset = do - hdr <- readHeader (ptr `plusPtr` offset) - return (jhTag hdr /= Empty) - -nextHeader :: JournalConsumer -> Ptr Word8 -> IO (Maybe JournalHeader) -nextHeader jc ptr = do - hdr <- readHeader ptr - case jhTag hdr of - Valid -> return (Just hdr) - Invalid -> nextHeader jc (ptr `plusPtr` (hEADER_SIZE + fromIntegral (jhLength hdr))) - Empty -> return Nothing - iterJournal :: Ptr Word8 -> AtomicCounter -> (a -> BS.ByteString -> a) -> a -> IO a iterJournal ptr consumed f x = do offset <- readCounter consumed diff --git a/src/journal/test/Journal/CRC32Test.hs b/src/journal/test/Journal/CRC32Test.hs index 27d9464d..68e42263 100644 --- a/src/journal/test/Journal/CRC32Test.hs +++ b/src/journal/test/Journal/CRC32Test.hs @@ -14,7 +14,7 @@ import Journal.CRC32 (crc32) ------------------------------------------------------------------------ -foreign import ccall "zlib.h crc32" +foreign import ccall unsafe "zlib.h crc32" zlib_crc32 :: CULong -> CString -> CUInt -> CULong zlibCrc32 :: ByteString -> IO Word32