Hoogle Search
Within LTS Haskell 24.52 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
pooledMallocArray :: Storable a => Pool -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Allocate storage for the given number of elements of a storable type in the pool.
pooledMallocArray0 :: Storable a => Pool -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Allocate storage for the given number of elements of a storable type in the pool, but leave room for an extra element to signal the end of the array.
pooledMallocBytes :: Pool -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Allocate the given number of bytes of storage in the pool.
pooledRealloc :: Storable a => Pool -> Ptr a -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Adjust the storage area for an element in the pool to the given size of the required type.
pooledReallocArray :: Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Adjust the size of an array in the given pool.
pooledReallocArray0 :: Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Adjust the size of an array with an end marker in the given pool.
pooledReallocBytes :: Pool -> Ptr a -> Int -> IO (Ptr a)ghc-internal GHC.Internal.Foreign.Marshal.Pool Adjust the storage area for an element in the pool to the given size. Note that the previously allocated space is still retained in the same Pool and will only be freed when the entire Pool is freed.
MallocPtr :: MutableByteArray# RealWorld -> !IORef Finalizers -> ForeignPtrContentsghc-internal GHC.Internal.ForeignPtr The pointer refers to a byte array. The MutableByteArray# field means that the MutableByteArray# is reachable (by GC) whenever the ForeignPtr is reachable. When the ForeignPtr becomes unreachable, the runtime's normal GC recovers the memory backing it. Here, the finalizer function intended to be used to free() any ancillary *unmanaged* memory pointed to by the MutableByteArray#. See the zlib library for an example of this use.
- Invariant: The Addr# in the parent ForeignPtr is an interior pointer into this MutableByteArray#.
- Invariant: The MutableByteArray# is pinned, so the Addr# does not get invalidated by the GC moving the byte array.
- Invariant: A MutableByteArray# must not be associated with more than one set of finalizers. For example, this is sound:
incrGood :: ForeignPtr Word8 -> ForeignPtr Word8 incrGood (ForeignPtr p (MallocPtr m f)) = ForeignPtr (plusPtr p 1) (MallocPtr m f)
But this is unsound:incrBad :: ForeignPtr Word8 -> IO (ForeignPtr Word8) incrBad (ForeignPtr p (MallocPtr m _)) = do f <- newIORef NoFinalizers pure (ForeignPtr p (MallocPtr m f))
mallocForeignPtr :: Storable a => IO (ForeignPtr a)ghc-internal GHC.Internal.ForeignPtr Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded. mallocForeignPtr is equivalent to
do { p <- malloc; newForeignPtr finalizerFree p }although it may be implemented differently internally: you may not assume that the memory returned by mallocForeignPtr has been allocated with malloc. GHC notes: mallocForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, so the ForeignPtr does not require a finalizer to free the memory. Use of mallocForeignPtr and associated functions is strongly recommended in preference to newForeignPtr with a finalizer.mallocForeignPtrAlignedBytes :: Int -> Int -> IO (ForeignPtr a)ghc-internal GHC.Internal.ForeignPtr This function is similar to mallocForeignPtrBytes, except that the size and alignment of the memory required is given explicitly as numbers of bytes.