X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FMarshal%2FArray.hs;h=1ca3e9e2365ea39afc58c6d29e05eaac4a6d87f6;hb=41e8fba828acbae1751628af50849f5352b27873;hp=8d8da7b5f1fc8b5c75d8de9a88db54c762f497f3;hpb=e70ccaa8e39155954759cc90eeae57d6bfdb5088;p=ghc-base.git diff --git a/Foreign/Marshal/Array.hs b/Foreign/Marshal/Array.hs index 8d8da7b..1ca3e9e 100644 --- a/Foreign/Marshal/Array.hs +++ b/Foreign/Marshal/Array.hs @@ -1,4 +1,5 @@ -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash #-} + ----------------------------------------------------------------------------- -- | -- Module : Foreign.Marshal.Array @@ -63,8 +64,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 +102,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.