[commit: array] master: Use count argument in hPutArray/hGetArray. Fixes #4827 (bdf4ce7)
Max Bolingbroke
batterseapower at hotmail.com
Tue Apr 5 23:49:06 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/array
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/bdf4ce746aefb2cfb3c767e0f458b653238c1672
>---------------------------------------------------------------
commit bdf4ce746aefb2cfb3c767e0f458b653238c1672
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date: Tue Apr 5 22:48:26 2011 +0100
Use count argument in hPutArray/hGetArray. Fixes #4827
>---------------------------------------------------------------
Data/Array/IO.hs | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Data/Array/IO.hs b/Data/Array/IO.hs
index f36ab29..e7c1712 100644
--- a/Data/Array/IO.hs
+++ b/Data/Array/IO.hs
@@ -74,8 +74,8 @@ hGetArray handle (IOUArray (STUArray _l _u n ptr)) count
-- we would like to read directly into the buffer, but we can't
-- be sure that the MutableByteArray# is pinned, so we have to
-- allocate a separate area of memory and copy.
- allocaBytes n $ \p -> do
- r <- hGetBuf handle p n
+ allocaBytes count $ \p -> do
+ r <- hGetBuf handle p count
memcpy_ba_ptr ptr p (fromIntegral r)
return r
@@ -98,9 +98,9 @@ hPutArray handle (IOUArray (STUArray _l _u n raw)) count
| otherwise = do
-- as in hGetArray, we would like to use the array directly, but
-- we can't be sure that the MutableByteArray# is pinned.
- allocaBytes n $ \p -> do
- memcpy_ptr_ba p raw (fromIntegral n)
- hPutBuf handle p n
+ allocaBytes count $ \p -> do
+ memcpy_ptr_ba p raw (fromIntegral count)
+ hPutBuf handle p count
foreign import ccall unsafe "memcpy"
memcpy_ptr_ba :: Ptr a -> MutableByteArray# RealWorld -> CSize -> IO (Ptr ())
More information about the Cvs-libraries
mailing list