2{-# LANGUAGE ExistentialQuantification #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE FlexibleContexts #-}
10-- Module : Streamly.Memory.Malloc
11-- Copyright : (c) 2019 Composewell Technologies
14-- Maintainer : streamly@composewell.com
15-- Stability : experimental
18module Streamly.Memory.Malloc
20 mallocForeignPtrAlignedBytes
21 , mallocForeignPtrAlignedUnmanagedBytes
27import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
28import Foreign.Marshal.Alloc (mallocBytes)
30import Foreign.ForeignPtr (newForeignPtr)
31import Foreign.Marshal.Alloc (finalizerFree)
34import qualified GHC.ForeignPtr as GHC
36{-# INLINE mallocForeignPtrAlignedBytes #-}
37mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
39mallocForeignPtrAlignedBytes =
40 GHC.mallocPlainForeignPtrAlignedBytes
42mallocForeignPtrAlignedBytes size _alignment = do
44 newForeignPtr finalizerFree p
47-- memalign alignment size
48-- foreign import ccall unsafe "stdlib.h posix_memalign" _memalign :: CSize -> CSize -> IO (Ptr a)
50mallocForeignPtrAlignedUnmanagedBytes :: Int -> Int -> IO (ForeignPtr a)
51mallocForeignPtrAlignedUnmanagedBytes size _alignment = do
52 -- XXX use posix_memalign/aligned_alloc for aligned allocation
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list