Skip to content

Commit

Permalink
using copyBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Oct 30, 2023
1 parent 5bce041 commit 867c5a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Network/HPACK/HeaderBlock/Encode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ module Network.HPACK.HeaderBlock.Encode (
import Control.Exception (bracket, throwIO)
import qualified Control.Exception as E
import qualified Data.ByteString as BS
import Data.ByteString.Internal (create, memcpy)
import Data.ByteString.Internal (create)
import Data.IORef
import Foreign.Marshal.Alloc (free, mallocBytes)
import Foreign.Marshal.Utils (copyBytes)
import Foreign.Ptr (minusPtr)
import Network.ByteOrder

Expand Down Expand Up @@ -70,7 +71,7 @@ encodeHeader' stgy siz dyntbl hs = bracket (mallocBytes siz) free enc
enc buf = do
(hs', len) <- encodeTokenHeader buf siz stgy True dyntbl hs
case hs' of
[] -> create len $ \p -> memcpy p buf len
[] -> create len $ \p -> copyBytes p buf len
_ -> throwIO BufferOverrun

----------------------------------------------------------------
Expand Down

0 comments on commit 867c5a9

Please sign in to comment.