4-- Module : Streamly.Memory.Malloc
5-- Copyright : (c) 2019 Composewell Technologies
8-- Maintainer : streamly@composewell.com
9-- Stability : experimental
12module Streamly.Memory.Malloc
14 mallocForeignPtrAlignedBytes
15 , mallocForeignPtrAlignedUnmanagedBytes
21import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
22import Foreign.Marshal.Alloc (mallocBytes)
24import Foreign.ForeignPtr (newForeignPtr)
25import Foreign.Marshal.Alloc (finalizerFree)
28import qualified GHC.ForeignPtr as GHC
30{-# INLINE mallocForeignPtrAlignedBytes #-}
31mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
33mallocForeignPtrAlignedBytes =
34 GHC.mallocPlainForeignPtrAlignedBytes
36mallocForeignPtrAlignedBytes size _alignment = do
38 newForeignPtr finalizerFree p
41-- memalign alignment size
42-- foreign import ccall unsafe "stdlib.h posix_memalign" _memalign :: CSize -> CSize -> IO (Ptr a)
44mallocForeignPtrAlignedUnmanagedBytes :: Int -> Int -> IO (ForeignPtr a)
45mallocForeignPtrAlignedUnmanagedBytes size _alignment = do
46 -- 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