1{-# LANGUAGE TypeFamilies #-}
6-- Module : Streamly.Memory.Malloc
7-- Copyright : (c) 2019 Composewell Technologies
10-- Maintainer : streamly@composewell.com
11-- Stability : experimental
14module Streamly.Memory.Malloc
16 mallocForeignPtrAlignedBytes
17 , mallocForeignPtrAlignedUnmanagedBytes
23import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
24import Foreign.Marshal.Alloc (mallocBytes)
26import Foreign.ForeignPtr (newForeignPtr)
27import Foreign.Marshal.Alloc (finalizerFree)
30import qualified GHC.ForeignPtr as GHC
32{-# INLINE mallocForeignPtrAlignedBytes #-}
33mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
35mallocForeignPtrAlignedBytes =
36 GHC.mallocPlainForeignPtrAlignedBytes
38mallocForeignPtrAlignedBytes size _alignment = do
40 newForeignPtr finalizerFree p
43-- memalign alignment size
44-- foreign import ccall unsafe "stdlib.h posix_memalign" _memalign :: CSize -> CSize -> IO (Ptr a)
46mallocForeignPtrAlignedUnmanagedBytes :: Int -> Int -> IO (ForeignPtr a)
47mallocForeignPtrAlignedUnmanagedBytes size _alignment = do
48 -- 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