Like malloc but memory is filled with bytes of value zero.
Modulebase-compat-0.14.1Haskell2010
Foreign.Marshal.Safe.Compat
- 1 type
- 64 values
- Packagebase-compat-0.14.1
- Exports65
- LanguageHaskell2010
- LicenceMIT
- SourceAlloc.hs
The module Foreign.Marshal.Safe re-exports the other modules in the
Foreign.Marshal hierarchy:
Like mallocBytes, but memory is filled with bytes of value zero.
alloca f executes the computation f, passing as argument
a pointer to a temporarily allocated block of memory sufficient to
hold values of type a.
The memory is freed when f terminates (either normally or via an
exception), so the pointer passed to f must not be used after this.
allocaBytes n f executes the computation f, passing as argument
a pointer to a temporarily allocated block of memory of n bytes.
The block of memory is sufficiently aligned for any of the basic
foreign types that fits into a memory block of the allocated size.
The memory is freed when f terminates (either normally or via an
exception), so the pointer passed to f must not be used after this.
allocaBytesAligned size align f executes the computation f,
passing as argument a pointer to a temporarily allocated block of memory
of size bytes and aligned to align bytes. The value of align must
be a power of two.
The memory is freed when f terminates (either normally or via an
exception), so the pointer passed to f must not be used after this.
A pointer to a foreign function equivalent to free, which may be used as a finalizer (cf ForeignPtr) for storage allocated with malloc, mallocBytes, realloc or reallocBytes.
Free a block of memory that was allocated with malloc,
mallocBytes, realloc, reallocBytes, new
or any of the newX functions in Foreign.Marshal.Array or
Foreign.C.String.
Allocate a block of memory that is sufficient to hold values of type
a. The size of the area allocated is determined by the sizeOf
method from the instance of Storable for the appropriate type.
The memory may be deallocated using free or finalizerFree when no longer required.
Allocate a block of memory of the given number of bytes. The block of memory is sufficiently aligned for any of the basic foreign types that fits into a memory block of the allocated size.
The memory may be deallocated using free or finalizerFree when no longer required.
Resize a memory area that was allocated with malloc or mallocBytes
to the size needed to store values of type b. The returned pointer
may refer to an entirely different memory area, but will be suitably
aligned to hold values of type b. The contents of the referenced
memory area will be the same as of the original pointer up to the
minimum of the original size and the size of values of type b.
If the argument to realloc is nullPtr, realloc behaves like malloc.
Resize a memory area that was allocated with malloc or mallocBytes to the given size. The returned pointer may refer to an entirely different memory area, but will be sufficiently aligned for any of the basic foreign types that fits into a memory block of the given size. The contents of the referenced memory area will be the same as of the original pointer up to the minimum of the original size and the given size.
If the pointer argument to reallocBytes is nullPtr, reallocBytes behaves like malloc. If the requested size is 0, reallocBytes behaves like free.
Like mallocArray, but allocated memory is filled with bytes of value zero.
Like callocArray0, but allocated memory is filled with bytes of value zero.
Advance a pointer into an array by the given number of elements
Temporarily allocate space for the given number of elements (like alloca, but for multiple elements).
Like allocaArray, but add an extra position to hold a special termination element.
Copy the given number of elements from the second array (source) into the first array (destination); the copied areas may not overlap
Return the number of elements in an array, excluding the terminator
Allocate storage for the given number of elements of a storable type (like malloc, but for multiple elements).
Like mallocArray, but add an extra position to hold a special termination element.
Copy the given number of elements from the second array (source) into the first array (destination); the copied areas may overlap
Write a list of storable elements into a newly allocated, consecutive sequence of storable values (like new, but for multiple elements).
Write a list of storable elements into a newly allocated, consecutive sequence of storable values, where the end is fixed by the given end marker
Convert an array of given length into a Haskell list. The implementation is tail-recursive and so uses constant stack space.
Convert an array terminated by the given end marker into a Haskell list
Write the list elements consecutive into memory
Write the list elements consecutive into memory and terminate them with the given marker element
Adjust the size of an array
Adjust the size of an array including an extra position for the end marker.
Temporarily store a list of storable values in memory (like with, but for multiple elements).
Like withArray, but a terminator indicates where the array ends
Like withArray, but the action gets the number of values as an additional parameter
Like withArrayLen, but a terminator indicates where the array ends
throwIf Guards against negative result values
Like throwIfNeg, but discarding the result
Guards against null pointers
Like throwIf, but discarding the result
A memory pool.
Deallocate a memory pool and everything which has been allocated in the pool itself.
Allocate a fresh memory pool.
Allocate storage for the given number of elements of a storable type in the 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.
Allocate the given number of bytes of storage in the pool.
Allocate storage for a value in the given pool and marshal the value into this storage.
Allocate consecutive storage for a list of values in the given pool and marshal these values into it.
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.
Adjust the storage area for an element in the pool to the given size of the required type.
Adjust the size of an array in the given pool.
Adjust the size of an array with an end marker in the given pool.
Execute an action with a fresh memory pool, which gets automatically deallocated (including its contents) after the action has finished.
Fill a given number of bytes in memory area with a byte value.
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may not overlap
Convert a Haskell Bool to its numeric representation
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may overlap
Convert a Boolean in numeric representation to a Haskell value
with val f executes the computation f, passing as argument
a pointer to a temporarily allocated block of memory into which
val has been marshalled (the combination of alloca and poke).
The memory is freed when f terminates (either normally or via an
exception), so the pointer passed to f must not be used after this.
Replicates a withXXX combinator over a list of objects, yielding a list of
marshalled objects