Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype MLockedForeignPtr a = SFP {}
- withMLockedForeignPtr ∷ MonadST m ⇒ MLockedForeignPtr a → (Ptr a → m b) → m b
- finalizeMLockedForeignPtr ∷ MonadST m ⇒ MLockedForeignPtr a → m ()
- traceMLockedForeignPtr ∷ (Storable a, Show a, MonadST m) ⇒ MLockedForeignPtr a → m ()
- mlockedMalloc ∷ MonadST m ⇒ MLockedAllocator m
- newtype MLockedAllocator m = MLockedAllocator {
- mlAllocate ∷ ∀ a. CSize → m (MLockedForeignPtr a)
- mlockedAlloca ∷ ∀ a b m. (MonadST m, MonadThrow m) ⇒ CSize → (Ptr a → m b) → m b
- mlockedAllocaSized ∷ ∀ m n b. (MonadST m, MonadThrow m, KnownNat n) ⇒ (SizedPtr n → m b) → m b
- mlockedAllocForeignPtr ∷ ∀ a m. (MonadST m, Storable a) ⇒ m (MLockedForeignPtr a)
- mlockedAllocForeignPtrBytes ∷ MonadST m ⇒ CSize → CSize → m (MLockedForeignPtr a)
- mlockedAllocaWith ∷ ∀ a b m. (MonadThrow m, MonadST m) ⇒ MLockedAllocator m → CSize → (Ptr a → m b) → m b
- mlockedAllocaSizedWith ∷ ∀ m n b. (MonadST m, MonadThrow m, KnownNat n) ⇒ MLockedAllocator m → (SizedPtr n → m b) → m b
- mlockedAllocForeignPtrWith ∷ ∀ a m. Storable a ⇒ MLockedAllocator m → m (MLockedForeignPtr a)
- mlockedAllocForeignPtrBytesWith ∷ MLockedAllocator m → CSize → CSize → m (MLockedForeignPtr a)
- newtype ForeignPtr (m ∷ Type → Type) a = ForeignPtr {}
- mallocForeignPtrBytes ∷ MonadST m ⇒ Int → m (ForeignPtr m a)
- withForeignPtr ∷ MonadST m ⇒ ForeignPtr m a → (Ptr a → m b) → m b
- zeroMem ∷ MonadST m ⇒ Ptr a → CSize → m ()
- copyMem ∷ MonadST m ⇒ Ptr a → Ptr a → CSize → m ()
- allocaBytes ∷ (MonadThrow m, MonadST m) ⇒ Int → (Ptr a → m b) → m b
- unpackByteStringCStringLen ∷ (MonadThrow m, MonadST m) ⇒ ByteString → (CStringLen → m a) → m a
- packByteStringCStringLen ∷ MonadST m ⇒ CStringLen → m ByteString
- unsafeIOToMonadST ∷ MonadST m ⇒ IO a → m a
High-level memory management
newtype MLockedForeignPtr a Source #
Foreign pointer to securely allocated memory.
Instances
NFData (MLockedForeignPtr a) Source # | |
Defined in Cardano.Crypto.Libsodium.Memory.Internal rnf ∷ MLockedForeignPtr a → () Source # | |
NoThunks (MLockedForeignPtr a) Source # | |
Defined in Cardano.Crypto.Libsodium.Memory.Internal |
withMLockedForeignPtr ∷ MonadST m ⇒ MLockedForeignPtr a → (Ptr a → m b) → m b Source #
finalizeMLockedForeignPtr ∷ MonadST m ⇒ MLockedForeignPtr a → m () Source #
traceMLockedForeignPtr ∷ (Storable a, Show a, MonadST m) ⇒ MLockedForeignPtr a → m () Source #
Warning: Do not use traceMLockedForeignPtr in production
MLocked allocations
mlockedMalloc ∷ MonadST m ⇒ MLockedAllocator m Source #
newtype MLockedAllocator m Source #
MLockedAllocator | |
|
mlockedAlloca ∷ ∀ a b m. (MonadST m, MonadThrow m) ⇒ CSize → (Ptr a → m b) → m b Source #
mlockedAllocaSized ∷ ∀ m n b. (MonadST m, MonadThrow m, KnownNat n) ⇒ (SizedPtr n → m b) → m b Source #
mlockedAllocForeignPtr ∷ ∀ a m. (MonadST m, Storable a) ⇒ m (MLockedForeignPtr a) Source #
mlockedAllocForeignPtrBytes ∷ MonadST m ⇒ CSize → CSize → m (MLockedForeignPtr a) Source #
Allocations using an explicit allocator
mlockedAllocaWith ∷ ∀ a b m. (MonadThrow m, MonadST m) ⇒ MLockedAllocator m → CSize → (Ptr a → m b) → m b Source #
mlockedAllocaSizedWith ∷ ∀ m n b. (MonadST m, MonadThrow m, KnownNat n) ⇒ MLockedAllocator m → (SizedPtr n → m b) → m b Source #
mlockedAllocForeignPtrWith ∷ ∀ a m. Storable a ⇒ MLockedAllocator m → m (MLockedForeignPtr a) Source #
mlockedAllocForeignPtrBytesWith ∷ MLockedAllocator m → CSize → CSize → m (MLockedForeignPtr a) Source #
ForeignPtr
operations, generalized to MonadST
newtype ForeignPtr (m ∷ Type → Type) a Source #
A ForeignPtr
type, generalized to MonadST
. The type is tagged with
the correct Monad m
in order to ensure that foreign pointers created in
one ST context can only be used within the same ST context.
mallocForeignPtrBytes ∷ MonadST m ⇒ Int → m (ForeignPtr m a) Source #
withForeignPtr ∷ MonadST m ⇒ ForeignPtr m a → (Ptr a → m b) → m b Source #
withForeignPtr
, generalized to MonadST
.
Caveat: if the monadic action passed to withForeignPtr
does not terminate
(e.g., forever
), the ForeignPtr
finalizer may run prematurely.
Unmanaged memory, generalized to MonadST
allocaBytes ∷ (MonadThrow m, MonadST m) ⇒ Int → (Ptr a → m b) → m b Source #
ByteString memory access, generalized to MonadST
unpackByteStringCStringLen ∷ (MonadThrow m, MonadST m) ⇒ ByteString → (CStringLen → m a) → m a Source #
Unpacks a ByteString into a temporary buffer and runs the provided ST
function on it.
packByteStringCStringLen ∷ MonadST m ⇒ CStringLen → m ByteString Source #
Helper
unsafeIOToMonadST ∷ MonadST m ⇒ IO a → m a Source #