cardano-crypto-class-2.2.0.0: Type classes abstracting over cryptography primitives for Cardano
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Crypto.Libsodium.Memory.Internal

Synopsis

High-level memory management

newtype MLockedForeignPtr a Source #

Foreign pointer to securely allocated memory.

Constructors

SFP 

withMLockedForeignPtrMonadST m ⇒ MLockedForeignPtr a → (Ptr a → m b) → m b Source #

traceMLockedForeignPtr ∷ (Storable a, Show a, MonadST m) ⇒ MLockedForeignPtr a → m () Source #

Warning: Do not use traceMLockedForeignPtr in production

MLocked allocations

newtype MLockedAllocator m Source #

Constructors

MLockedAllocator 

Fields

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 #

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 #

ForeignPtr operations, generalized to MonadST

newtype ForeignPtr (m ∷ TypeType) 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.

Constructors

ForeignPtr 

withForeignPtrMonadST 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

zeroMemMonadST m ⇒ Ptr a → CSize → m () Source #

copyMemMonadST m ⇒ Ptr a → Ptr a → CSize → m () Source #

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.

Helper

unsafeIOToMonadSTMonadST m ⇒ IO a → m a Source #