@@ -16,11 +16,12 @@ module Streamly.Memory.Malloc
1616 )
1717where
1818
19−#define USE_GHC_MALLOC
19+
20+-- We use GHC malloc by default
2021
2122import Foreign.ForeignPtr (ForeignPtr, newForeignPtr_)
2223import Foreign.Marshal.Alloc (mallocBytes)
23−#ifndef USE_GHC_MALLOC
24+#ifdef USE_C_MALLOC
2425import Foreign.ForeignPtr (newForeignPtr)
2526import Foreign.Marshal.Alloc (finalizerFree)
2627#endif
@@ -29,13 +30,13 @@ import qualified GHC.ForeignPtr as GHC
2930
3031{-# INLINE mallocForeignPtrAlignedBytes #-}
3132mallocForeignPtrAlignedBytes :: Int -> Int -> IO (GHC.ForeignPtr a)
32−#ifdef USE_GHC_MALLOC
33−mallocForeignPtrAlignedBytes =
34− GHC.mallocPlainForeignPtrAlignedBytes
35−#else
33+#ifdef USE_C_MALLOC
3634mallocForeignPtrAlignedBytes size _alignment = do
3735 p <- mallocBytes size
3836 newForeignPtr finalizerFree p
37+#else
38+mallocForeignPtrAlignedBytes =
39+ GHC.mallocPlainForeignPtrAlignedBytes
3940#endif
4041
4142-- memalign alignment size