2{-# LANGUAGE BangPatterns #-}
3{-# LANGUAGE ExistentialQuantification #-}
4{-# LANGUAGE MagicHash #-}
5{-# LANGUAGE RecordWildCards #-}
6{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE UnboxedTuples #-}
9{-# LANGUAGE FlexibleContexts #-}
14-- Module : Streamly.Memory.Malloc
15-- Copyright : (c) 2019 Composewell Technologies
18-- Maintainer : streamly@composewell.com
19-- Stability : experimental
22module Streamly.Memory.Malloc
24 mallocForeignPtrAlignedBytes
25 , mallocForeignPtrAlignedUnmanagedBytes
31import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
32import Foreign.Marshal.Alloc (mallocBytes)
34import Foreign.ForeignPtr (newForeignPtr)
35import Foreign.Marshal.Alloc (finalizerFree)
38import qualified GHC.ForeignPtr as GHC
40{-# INLINE mallocForeignPtrAlignedBytes #-}
41mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
43mallocForeignPtrAlignedBytes size alignment = do
44 GHC.mallocPlainForeignPtrAlignedBytes size alignment
46mallocForeignPtrAlignedBytes size _alignment = do
48 newForeignPtr finalizerFree p
51-- memalign alignment size
52-- foreign import ccall unsafe "stdlib.h posix_memalign" _memalign :: CSize -> CSize -> IO (Ptr a)
54mallocForeignPtrAlignedUnmanagedBytes :: Int -> Int -> IO (ForeignPtr a)
55mallocForeignPtrAlignedUnmanagedBytes size _alignment = do
56 -- 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