Add cstring#
This commit is contained in:
parent
a51dcb65b6
commit
2e279c62f2
2 changed files with 7 additions and 1 deletions
|
@ -9,6 +9,7 @@ to ease the migration process.
|
|||
|
||||
* Fix `doubleDec`, which was encoding small numbers incorrectly.
|
||||
* Add `runByteString` for producing `ByteString` from bounded builders.
|
||||
* Add `cstring#` for producing builder from `Addr#`.
|
||||
* Correct the required length calculation for json string encoding.
|
||||
|
||||
## 0.3.7.0 -- 2020-11-06
|
||||
|
|
|
@ -29,6 +29,7 @@ module Data.Bytes.Builder
|
|||
, shortTextUtf8
|
||||
, shortTextJsonString
|
||||
, cstring
|
||||
, cstring#
|
||||
, cstringLen
|
||||
, stringUtf8
|
||||
-- * Encode Integral Types
|
||||
|
@ -153,7 +154,7 @@ import Foreign.C.String (CStringLen)
|
|||
import GHC.ByteOrder (ByteOrder(BigEndian,LittleEndian),targetByteOrder)
|
||||
import GHC.Exts (Int(I#),Char(C#),Int#,State#,ByteArray#,(>=#))
|
||||
import GHC.Exts (RealWorld,(+#),(-#),(<#))
|
||||
import GHC.Exts ((*#))
|
||||
import GHC.Exts (Addr#,(*#))
|
||||
import GHC.Integer.Logarithms.Compat (integerLog2#)
|
||||
import GHC.IO (IO(IO),stToIO)
|
||||
import GHC.Natural (naturalFromInteger,naturalToInteger)
|
||||
|
@ -391,6 +392,10 @@ copy (Bytes (ByteArray src# ) (I# soff# ) (I# slen# )) = Builder
|
|||
where
|
||||
!(I# newSz) = max (I# slen#) 4080
|
||||
|
||||
cstring# :: Addr# -> Builder
|
||||
{-# inline cstring# #-}
|
||||
cstring# x = cstring (Exts.Ptr x)
|
||||
|
||||
-- | Create a builder from a C string with explicit length. The builder
|
||||
-- must be executed before the C string is freed.
|
||||
cstringLen :: CStringLen -> Builder
|
||||
|
|
Loading…
Reference in a new issue