Skip to content

Commit

Permalink
Fixes #10 - memory leak in arrayOf.
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrap committed Aug 25, 2016
1 parent be82ee5 commit 080c532
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Data/JsonStream/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ array' valparse = Parser $ \tp ->
(TokFailed) -> Failed "Array - token failed"
where
nextitem _ _ (ArrayEnd ctx) ntok = Done ctx ntok
nextitem i tok _ _ = arrcontent i (callParse (valparse i) tok)
nextitem !i tok _ _ = arrcontent i (callParse (valparse i) tok)

arrcontent i (Done _ ntp) = moreData (nextitem (i+1)) ntp
arrcontent i (MoreData (Parser np, ntp)) = MoreData (Parser (arrcontent i . np), ntp)
arrcontent i (Yield v np) = Yield v (arrcontent i np)
arrcontent !i (Done _ ntp) = moreData (nextitem (i+1)) ntp
arrcontent !i (MoreData (Parser np, ntp)) = MoreData (Parser (arrcontent i . np), ntp)
arrcontent !i (Yield v np) = Yield v (arrcontent i np)
arrcontent _ (Failed err) = Failed err

-- | Match all items of an array.
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.4.1.1
Fixed memory leak in arrayOf

# 0.4.1.0
Added aeson-compatibile encode/decode functions.

Expand Down
2 changes: 1 addition & 1 deletion json-stream.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: json-stream
version: 0.4.1.0
version: 0.4.1.1
synopsis: Incremental applicative JSON parser
description: Easy to use JSON parser fully supporting incremental parsing.
Parsing grammar in applicative form.
Expand Down

0 comments on commit 080c532

Please sign in to comment.