Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The FFI task force 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerffi@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Foreign.Marshal.Array

Contents

Description

Marshalling support: routines allocating, storing, and retrieving Haskell lists that are represented as arrays in the foreign language

Synopsis

Marshalling arrays

Allocation

mallocArray ::Storable a =>Int ->IO (Ptr a)Source#

Allocate storage for the given number of elements of a storable type (likemalloc, but for multiple elements).

mallocArray0 ::Storable a =>Int ->IO (Ptr a)Source#

LikemallocArray, but add an extra position to hold a special termination element.

allocaArray ::Storable a =>Int -> (Ptr a ->IO b) ->IO bSource#

Temporarily allocate space for the given number of elements (likealloca, but for multiple elements).

allocaArray0 ::Storable a =>Int -> (Ptr a ->IO b) ->IO bSource#

LikeallocaArray, but add an extra position to hold a special termination element.

reallocArray ::Storable a =>Ptr a ->Int ->IO (Ptr a)Source#

Adjust the size of an array

reallocArray0 ::Storable a =>Ptr a ->Int ->IO (Ptr a)Source#

Adjust the size of an array including an extra position for the end marker.

callocArray ::Storable a =>Int ->IO (Ptr a)Source#

LikemallocArray, but allocated memory is filled with bytes of value zero.

callocArray0 ::Storable a =>Int ->IO (Ptr a)Source#

LikecallocArray0, but allocated memory is filled with bytes of value zero.

Marshalling

peekArray ::Storable a =>Int ->Ptr a ->IO [a]Source#

Convert an array of given length into a Haskell list. The implementation is tail-recursive and so uses constant stack space.

peekArray0 :: (Storable a,Eq a) => a ->Ptr a ->IO [a]Source#

Convert an array terminated by the given end marker into a Haskell list

pokeArray ::Storable a =>Ptr a -> [a] ->IO ()Source#

Write the list elements consecutive into memory

pokeArray0 ::Storable a => a ->Ptr a -> [a] ->IO ()Source#

Write the list elements consecutive into memory and terminate them with the given marker element

Combined allocation and marshalling

newArray ::Storable a => [a] ->IO (Ptr a)Source#

Write a list of storable elements into a newly allocated, consecutive sequence of storable values (likenew, but for multiple elements).

newArray0 ::Storable a => a -> [a] ->IO (Ptr a)Source#

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

withArray ::Storable a => [a] -> (Ptr a ->IO b) ->IO bSource#

Temporarily store a list of storable values in memory (likewith, but for multiple elements).

withArray0 ::Storable a => a -> [a] -> (Ptr a ->IO b) ->IO bSource#

LikewithArray, but a terminator indicates where the array ends

withArrayLen ::Storable a => [a] -> (Int ->Ptr a ->IO b) ->IO bSource#

LikewithArray, but the action gets the number of values as an additional parameter

withArrayLen0 ::Storable a => a -> [a] -> (Int ->Ptr a ->IO b) ->IO bSource#

LikewithArrayLen, but a terminator indicates where the array ends

Copying

(argument order: destination, source)

copyArray ::Storable a =>Ptr a ->Ptr a ->Int ->IO ()Source#

Copy the given number of elements from the second array (source) into the first array (destination); the copied areas maynot overlap

moveArray ::Storable a =>Ptr a ->Ptr a ->Int ->IO ()Source#

Copy the given number of elements from the second array (source) into the first array (destination); the copied areasmay overlap

Finding the length

lengthArray0 :: (Storable a,Eq a) => a ->Ptr a ->IOIntSource#

Return the number of elements in an array, excluding the terminator

Indexing

advancePtr ::Storable a =>Ptr a ->Int ->Ptr aSource#

Advance a pointer into an array by the given number of elements

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp