Skip to content

Commit

Permalink
refactor(journal): remove unused functions and use unsafe ffi
Browse files Browse the repository at this point in the history
Unsafe ffi is apparently only unsafe if the C code calls Haskell,
which shouldn't be happening in this case.
  • Loading branch information
symbiont-stevan-andjelkovic committed Dec 2, 2021
1 parent 5c91541 commit feca5c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions src/journal/src/Journal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/journal/test/Journal/CRC32Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit feca5c1

Please sign in to comment.