Skip to content

Commit 942e93c

Browse files
committed
Rename unsafePinnedCreateUsingPtr to unsafeCreateWithPtr'
1 parent 538c281 commit 942e93c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

core/src/Streamly/Internal/Data/MutArray/Type.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module Streamly.Internal.Data.MutArray.Type
117117
, fromChunksK
118118
, fromChunksRealloced -- fromSmallChunks
119119

120-
, unsafePinnedCreateUsingPtr
120+
, unsafeCreateWithPtr'
121121

122122
-- ** Random writes
123123
, putIndex
@@ -3526,18 +3526,18 @@ unsafeAsPtr arr f =
35263526
(arrContents arr)
35273527
(\ptr -> f (ptr `plusPtr` arrStart arr) (byteLength arr))
35283528

3529-
-- | @unsafePinnedCreateUsingPtr capacity populator@ creates a pinned array of
3529+
-- | @unsafeCreateWithPtr' capacity populator@ creates a pinned array of
35303530
-- @capacity@ bytes and invokes the @populator@ function to populate it.
35313531
-- @populator ptr len@ gets the pointer to the array and MUST return the amount
35323532
-- of the capacity populated in bytes.
35333533
--
35343534
-- /Unsafe/ because the populator is allowed to use the pointer only up to
35353535
-- specified length. In other words, bytes populated MUST be less than or equal
35363536
-- to the total capacity.
3537-
{-# INLINE unsafePinnedCreateUsingPtr #-}
3538-
unsafePinnedCreateUsingPtr
3537+
{-# INLINE unsafeCreateWithPtr' #-}
3538+
unsafeCreateWithPtr'
35393539
:: MonadIO m => Int -> (Ptr Word8 -> IO Int) -> m (MutArray Word8)
3540-
unsafePinnedCreateUsingPtr cap pop = do
3540+
unsafeCreateWithPtr' cap pop = do
35413541
(arr :: MutArray Word8) <- emptyOf' cap
35423542
len <- Unboxed.unsafeAsPtr (arrContents arr) pop
35433543
when (len > cap) (error (errMsg len))
@@ -3548,7 +3548,7 @@ unsafePinnedCreateUsingPtr cap pop = do
35483548
where
35493549

35503550
errMsg len =
3551-
"unsafePinnedCreateUsingPtr: length > capacity, "
3551+
"unsafeCreateWithPtr': length > capacity, "
35523552
++ "length = " ++ show len ++ ", "
35533553
++ "capacity = " ++ show cap
35543554

core/src/Streamly/Internal/FileSystem/Handle.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ import qualified Streamly.Internal.Data.StreamK.Type as K (mkStream)
178178
getChunk :: MonadIO m => Int -> Handle -> m (Array Word8)
179179
getChunk size h = liftIO $ do
180180
-- ptr <- mallocPlainForeignPtrAlignedBytes size (alignment (undefined :: Word8))
181-
arr <- MArray.unsafePinnedCreateUsingPtr size $ \p -> hGetBufSome h p size
181+
arr <- MArray.unsafeCreateWithPtr' size $ \p -> hGetBufSome h p size
182182
-- XXX shrink only if the diff is significant
183183
pure $ unsafeFreezeWithShrink arr
184184

src/Streamly/Internal/FileSystem/FD.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ openFile path mode = Handle . fst <$> FD.openFile path mode True
219219
readArrayUpto :: Int -> Handle -> IO (Array Word8)
220220
readArrayUpto size (Handle fd) = do
221221
arr <-
222-
MArray.unsafePinnedCreateUsingPtr size $ \p ->
222+
MArray.unsafeCreateWithPtr' size $ \p ->
223223
-- n <- hGetBufSome h p size
224224
#if MIN_VERSION_base(4,15,0)
225225
RawIO.read fd p 0 size

src/Streamly/Internal/Network/Socket.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import qualified Streamly.Internal.Data.Array as A
101101
( unsafeFreeze, unsafePinnedAsPtr, chunksOf',
102102
createOf', unsafeCreateOf, scanCompactMin )
103103
import qualified Streamly.Internal.Data.MutArray as MArray
104-
(unsafePinnedCreateUsingPtr)
104+
(unsafeCreateWithPtr')
105105
import qualified Streamly.Internal.Data.Stream as S (fromStreamK, Stream(..), Step(..))
106106
import qualified Streamly.Internal.Data.StreamK as K (mkStream)
107107

@@ -261,7 +261,7 @@ readArrayUptoWith
261261
-> h
262262
-> IO (Array Word8)
263263
readArrayUptoWith f size h = do
264-
arr <- MArray.unsafePinnedCreateUsingPtr size $ \p -> f h p size
264+
arr <- MArray.unsafeCreateWithPtr' size $ \p -> f h p size
265265
-- XXX shrink only if the diff is significant
266266
-- unsafeFreezeWithShrink
267267
pure $ A.unsafeFreeze arr

0 commit comments

Comments
 (0)