Skip to content

Commit

Permalink
fix(journal): more plusAddr and zero offset fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Jan 12, 2022
1 parent 4f49ad1 commit 96aa320
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/journal/src/Journal/Internal/ByteBufferPtr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,13 @@ indexWord8OffAddr bb offset@(I# offset#) = do
writeInt = writeIntOffAddr

writeIntOffAddr :: ByteBuffer -> Int -> Int -> IO ()
writeIntOffAddr bb ix@(I# ix#) (I# value#) = do
boundCheck bb ix
writeIntOffAddr bb offset@(I# offset#) (I# value#) = do
boundCheck bb offset
withForeignPtr (bbPtr bb) $ \(Ptr addr#) ->
IO $ \s ->
case writeIntOffAddr# addr# ix# value# s of
case writeIntOffAddr# (addr# `plusAddr#` offset#) 0# value# s of
s' -> (# s', () #)

-- writeWordOffArray#
-- writeArrayOffAddr#
-- writeFloatOffArray#
Expand All @@ -429,14 +430,12 @@ writeInt32OffAddr bb offset@(I# offset#) (I32# value#) = do
s' -> (# s', () #)

writeInt64OffAddr :: ByteBuffer -> Int -> Int64 -> IO ()
writeInt64OffAddr bb offset@(I# offset#) value = do
writeInt64OffAddr bb offset@(I# offset#) (I64# value#) = do
boundCheck bb offset
withForeignPtr (bbPtr bb) $ \(Ptr addr#) ->
IO $ \s ->
case writeInt64OffAddr# addr# offset# value# s of
case writeInt64OffAddr# (addr# `plusAddr#` offset#) 0# value# s of
s' -> (# s', () #)
where
I# value# = fromIntegral value

-- writeWord8OffArray#
-- writeWord16OffArray#
Expand Down

0 comments on commit 96aa320

Please sign in to comment.