4-- Module : Streamly.Internal.Foreign.Malloc
5-- Copyright : (c) 2019 Composewell Technologies
7-- License : BSD-3-Clause
8-- Maintainer : streamly@composewell.com
9-- Stability : experimental
12module Streamly.Internal.Foreign.Malloc
14 mallocForeignPtrAlignedBytes
15 , mallocForeignPtrAlignedUnmanagedBytes
20-- We use GHC malloc by default
22import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
23import Foreign.Marshal.Alloc (mallocBytes)
25import Foreign.ForeignPtr (newForeignPtr)
26import Foreign.Marshal.Alloc (finalizerFree)
29import qualified GHC.ForeignPtr as GHC
31{-# INLINE mallocForeignPtrAlignedBytes #-}
32mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
34mallocForeignPtrAlignedBytes size _alignment = do
36 newForeignPtr finalizerFree p
38mallocForeignPtrAlignedBytes =
39 GHC.mallocPlainForeignPtrAlignedBytes
42-- memalign alignment size
43-- foreign import ccall unsafe "stdlib.h posix_memalign" _memalign :: CSize -> CSize -> IO (Ptr a)
45mallocForeignPtrAlignedUnmanagedBytes :: Int -> Int -> IO (ForeignPtr a)
46mallocForeignPtrAlignedUnmanagedBytes size _alignment = do
47 -- 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