on master help sign in
Add Ring.startOf that returns the ringStart as a Ptr
e57424dadithyaov
src/Streamly/Memory/Ring.hs+5
@@ -14,6 +14,7 @@ module Streamly.Memory.Ring
14 , new
14 , new
15 , advance
15 , advance
16 , moveBy
16 , moveBy
17+ , startOf
17
18
18 -- * Modification
19 -- * Modification
19 , unsafeInsert
20 , unsafeInsert
@@ -58,6 +59,10 @@ data Ring a = Ring
58 , ringBound :: {-# UNPACK #-} !(Ptr a) -- first address beyond allocated memory
59 , ringBound :: {-# UNPACK #-} !(Ptr a) -- first address beyond allocated memory
59 }
60 }
60
61
62+-- | Get the first address of the ring as a pointer.
63+startOf :: Ring a -> Ptr a
64+startOf = unsafeForeignPtrToPtr . ringStart
65+
61-- | Create a new ringbuffer and return the ring buffer and the ringHead.
66-- | Create a new ringbuffer and return the ring buffer and the ringHead.
62-- Returns the ring and the ringHead, the ringHead is same as ringStart.
67-- Returns the ring and the ringHead, the ringHead is same as ringStart.
63{-# INLINE new #-}
68{-# INLINE new #-}