Commit 0d34321e authored by Simon Marlow's avatar Simon Marlow
Browse files

export allocaBytesAligned; make allocaArray use the correct alignment (#2917)

parent aae6f867
......@@ -40,6 +40,7 @@ module Foreign.Marshal.Alloc (
-- ** Local allocation
alloca, -- :: Storable a => (Ptr a -> IO b) -> IO b
allocaBytes, -- :: Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned, -- :: Int -> Int -> (Ptr a -> IO b) -> IO b
-- ** Dynamic allocation
malloc, -- :: Storable a => IO (Ptr a)
......
......@@ -63,8 +63,8 @@ module Foreign.Marshal.Array (
) where
import Foreign.Ptr (Ptr, plusPtr)
import Foreign.Storable (Storable(sizeOf,peekElemOff,pokeElemOff))
import Foreign.Marshal.Alloc (mallocBytes, allocaBytes, reallocBytes)
import Foreign.Storable (Storable(alignment,sizeOf,peekElemOff,pokeElemOff))
import Foreign.Marshal.Alloc (mallocBytes, allocaBytesAligned, reallocBytes)
import Foreign.Marshal.Utils (copyBytes, moveBytes)
#ifdef __GLASGOW_HASKELL__
......@@ -101,7 +101,8 @@ allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray = doAlloca undefined
where
doAlloca :: Storable a' => a' -> Int -> (Ptr a' -> IO b') -> IO b'
doAlloca dummy size = allocaBytes (size * sizeOf dummy)
doAlloca dummy size = allocaBytesAligned (size * sizeOf dummy)
(alignment dummy)
-- |Like 'allocaArray', but add an extra position to hold a special
-- termination element.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment