Data.Memory.PtrMethods

memory-0.11: memory and related abstraction stuff

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | Safe
Language | Haskell2010

Data.Memory.PtrMethods

Description

methods to manipulate raw memory representation

Synopsis

- memCreateTemporary :: Int -> (Ptr Word8 -> IO a) -> IO a
- memXor :: Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
- memXorWith :: Ptr Word8 -> Word8 -> Ptr Word8 -> Int -> IO ()
- memCopy :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()
- memSet :: Ptr Word8 -> Word8 -> Int -> IO ()
- memEqual :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool
- memConstEqual :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool
- memCompare :: Ptr Word8 -> Ptr Word8 -> Int -> IO Ordering

# Documentation

memCreateTemporary :: Int -> (Ptr Word8 -> IO a) -> IO a

Create a new temporary buffer

memXor :: Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()

xor bytes from source1 and source2 to destination

d = s1 xor s2

s1, nor s2 are modified unless d point to s1 or s2

memXorWith :: Ptr Word8 -> Word8 -> Ptr Word8 -> Int -> IO ()

xor bytes from source with a specific value to destination

d = replicate (sizeof s) v `xor` s

memCopy :: Ptr Word8 -> Ptr Word8 -> Int -> IO ()

Copy a set number of bytes from `src to` dst

memSet :: Ptr Word8 -> Word8 -> Int -> IO ()

Set `n number of bytes to the same value` v

memEqual :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool

Check if two piece of memory are equals

memConstEqual :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool

A constant time equality test for 2 Memory buffers

compared to normal equality function, this function will go over all the bytes present before yielding a result even when knowing the overall result early in the processing.

memCompare :: Ptr Word8 -> Ptr Word8 -> Int -> IO Ordering

Compare two piece of memory and returns how they compare