Skip to content

Commit

Permalink
fix memory leak when unpacking at top-level scope (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
marius311 authored Aug 14, 2020
1 parent ce98591 commit a5987f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/UnPack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ macro unpack(args)
kd = [:( $key = $UnPack.unpack($suitecase_instance, Val{$(Expr(:quote, key))}()) ) for key in items]
kdblock = Expr(:block, kd...)
expr = quote
$suitecase_instance = $suitecase # handles if suitecase is not a variable but an expression
local $suitecase_instance = $suitecase # handles if suitecase is not a variable but an expression
$kdblock
$suitecase_instance # return RHS of `=` as standard in Julia
end
Expand Down Expand Up @@ -148,7 +148,7 @@ function _pack_bang(args)
kd = [:( $UnPack.pack!($suitecase_instance, Val{$(Expr(:quote, key))}(), $key) ) for key in items]
kdblock = Expr(:block, kd...)
return quote
$suitecase_instance = $suitecase # handles if suitecase is not a variable but an expression
local $suitecase_instance = $suitecase # handles if suitecase is not a variable but an expression
$kdblock
($(items...),)
end
Expand Down

0 comments on commit a5987f7

Please sign in to comment.