on master help sign in
Add the nil API to foreign mutable array
commit25532f15a666b87c245c739e2bca3f0aed02803d authoradithyaov <adithya@composewell.com> dateSat 4 Dec 2021, 02:00 (5 years ago) parent24299b0
1 file changed+9−2
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+9−2
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+9−2
@@ -26,7 +26,7 @@ module Streamly.Internal.Data.Array.Foreign.Mut.Type
2626
2727 -- * Constructing and Writing
2828 -- ** Construction
29− -- , nil
29+ , nil
3030
3131 -- *** Uninitialized Arrays
3232 , newArray
@@ -273,7 +273,7 @@ import Prelude hiding
273273-- >>> import qualified Streamly.Internal.Data.Fold.Type as Fold
274274
275275-------------------------------------------------------------------------------
276−-- Array Data Type
276+-- Foreign helpers
277277-------------------------------------------------------------------------------
278278
279279foreign import ccall unsafe "string.h memcpy" c_memcpy
@@ -387,6 +387,13 @@ data Array a =
387387 , aBound :: {-# UNPACK #-} !(Ptr a) -- ^ first address beyond allocated memory
388388 }
389389
390+nil ::
391+#ifdef DEVBUILD
392+ Storable a =>
393+#endif
394+ Array a
395+nil = Array nilArrayContents nullPtr nullPtr nullPtr
396+
390397-- | @fromForeignPtrUnsafe foreignPtr end bound@ creates an 'Array' that starts
391398-- at the memory pointed by the @foreignPtr@, @end@ is the first unused
392399-- address, and @bound@ is the first address beyond the allocated memory.