HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Modulebase-4.23.0.0Haskell2010

Foreign.Marshal.Pool

This module contains support for pooled memory management. Under this scheme, (re-)allocations belong to a given pool, and everything in a pool is deallocated when the pool itself is deallocated. This is useful when alloca with its implicit allocation and deallocation is not flexible enough, but explicit uses of malloc and free are too awkward.

Contents
  1. Pool management
  2. (Re-)Allocation within a pool
  3. Combined allocation and marshalling
Synopsis
  • Packagebase-4.23.0.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePool.hs

Pool management

valuefreePool :: Pool -> IO ()

Deallocate a memory pool and everything which has been allocated in the pool itself.

valuewithPool :: (Pool -> IO b) -> IO b

Execute an action with a fresh memory pool, which gets automatically deallocated (including its contents) after the action has finished.

(Re-)Allocation within a pool

valuepooledReallocBytes :: Pool -> Ptr a -> Int -> IO (Ptr a)

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.

valuepooledMallocArray0 :: Storable a => Pool -> Int -> IO (Ptr a)

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.

Combined allocation and marshalling

valuepooledNewArray0 :: Storable a => Pool -> a -> [a] -> IO (Ptr a)

Allocate consecutive storage for a list of values in the given pool and marshal these values into it, terminating the end with the given marker.