From 5f57f4f7c5cb29e26d12f80cb1cad0c6e34a72cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 8 Nov 2026 10:11:37 +0100 Subject: Export ScrubbedBytes accessors from Storage.Backend --- src/Erebos/Storage/Backend.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Erebos') 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 )) -- cgit v1.2.3