diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-08 10:11:37 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-11-08 20:41:24 +0100 |
| commit | 5f57f4f7c5cb29e26d12f80cb1cad0c6e34a72cc (patch) | |
| tree | 4e7cb475ef8e9f937d178420f6dfcb6bfd0bd8ca /src/Erebos/Storage/Backend.hs | |
| parent | 3deb61e9f2c1970ebfea5812b6b7fed66d24fd8c (diff) | |
Export ScrubbedBytes accessors from Storage.Backend
Diffstat (limited to 'src/Erebos/Storage/Backend.hs')
| -rw-r--r-- | src/Erebos/Storage/Backend.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Erebos/Storage/Backend.hs b/src/Erebos/Storage/Backend.hs index c802d95..719e87f 100644 --- a/src/Erebos/Storage/Backend.hs +++ b/src/Erebos/Storage/Backend.hs @@ -12,15 +12,21 @@ module Erebos.Storage.Backend ( withStorageBackend, refDigestBytes, + allocateScrubbedBytes, + unsafeUseScrubbedBytesAsCStringLen, WatchID, startWatchID, nextWatchID, ) where import Control.Concurrent.MVar +import Data.ByteArray qualified as BA import Data.ByteString (ByteString) import Data.HashTable.IO qualified as HT +import Foreign.C.String +import Foreign.Ptr + import ConvertByteString import Erebos.Object.Internal import Erebos.Storage.Internal @@ -38,3 +44,9 @@ withStorageBackend Storage {..} f = f stBackend refDigestBytes :: RefDigest -> ByteString refDigestBytes = toByteString + +allocateScrubbedBytes :: Int -> (Ptr a -> IO ()) -> IO ScrubbedBytes +allocateScrubbedBytes len f = snd <$> BA.allocRet len f + +unsafeUseScrubbedBytesAsCStringLen :: ScrubbedBytes -> (CStringLen -> IO a) -> IO a +unsafeUseScrubbedBytesAsCStringLen sb f = withByteArray sb (\ptr -> f ( ptr, BA.length sb )) |