@@ -16,11 +16,12 @@ module Streamly.Memory.Malloc
19−#define USE_GHC_MALLOC
19+
20+-- We use GHC malloc by default
21import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
22import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
22import Foreign.Marshal.Alloc (mallocBytes)
23import Foreign.Marshal.Alloc (mallocBytes)
23−#ifndef USE_GHC_MALLOC
24+#ifdef USE_C_MALLOC
24import Foreign.ForeignPtr (newForeignPtr)
25import Foreign.ForeignPtr (newForeignPtr)
25import Foreign.Marshal.Alloc (finalizerFree)
26import Foreign.Marshal.Alloc (finalizerFree)
@@ -29,13 +30,13 @@ import qualified GHC.ForeignPtr as GHC
30{-# INLINE mallocForeignPtrAlignedBytes #-}
31{-# INLINE mallocForeignPtrAlignedBytes #-}
31mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
32mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
32−#ifdef USE_GHC_MALLOC
33+#ifdef USE_C_MALLOC
33−mallocForeignPtrAlignedBytes =
34− GHC.mallocPlainForeignPtrAlignedBytes
36mallocForeignPtrAlignedBytes size _alignment = do
34mallocForeignPtrAlignedBytes size _alignment = do
37 p <- mallocBytes size
35 p <- mallocBytes size
38 newForeignPtr finalizerFree p
36 newForeignPtr finalizerFree p
38+mallocForeignPtrAlignedBytes =
39+ GHC.mallocPlainForeignPtrAlignedBytes
41-- memalign alignment size
42-- memalign alignment size