diff options
author | Tamar Christina <tamar@zhox.com> | 2020-10-06 09:46:33 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-10-09 08:50:13 -0400 |
commit | 6f0243ae5b359124936a8ff3dd0a287df3d7aca2 (patch) | |
tree | 34ab78371ab8119bb4d08a9a5430ab3679dbda61 /libraries | |
parent | c832f7e2a9314cfd61257cb161b1795b612d12b5 (diff) | |
download | haskell-6f0243ae5b359124936a8ff3dd0a287df3d7aca2.tar.gz |
winio: fix array splat
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Event/Array.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libraries/base/GHC/Event/Array.hs b/libraries/base/GHC/Event/Array.hs index a24f5f34c1..3a92538221 100644 --- a/libraries/base/GHC/Event/Array.hs +++ b/libraries/base/GHC/Event/Array.hs @@ -142,13 +142,17 @@ unsafeLoad (Array ref) load = do -- | Reads n elements from the pointer and copies them -- into the array. -unsafeCopyFromBuffer :: Array a -> Ptr a -> Int -> IO () +unsafeCopyFromBuffer :: Storable a => Array a -> Ptr a -> Int -> IO () unsafeCopyFromBuffer (Array ref) sptr n = readIORef ref >>= \(AC es _ cap) -> - CHECK_BOUNDS("unsafeCopyFromBuffer", cap, n-1) + CHECK_BOUNDS("unsafeCopyFromBuffer", cap, n) withForeignPtr es $ \pdest -> do - _ <- memcpy pdest sptr (fromIntegral n) + let size = sizeOfPtr sptr undefined + _ <- memcpy pdest sptr (fromIntegral $ n * size) writeIORef ref (AC es n cap) + where + sizeOfPtr :: Storable a => Ptr a -> a -> Int + sizeOfPtr _ a = sizeOf a ensureCapacity :: Storable a => Array a -> Int -> IO () ensureCapacity (Array ref) c = do |