Skip to content

Commit

Permalink
bug in finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jan 3, 2018
1 parent ecba0ff commit a244510
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/RawFile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,20 @@ end

import Base.start,Base.next,Base.done,Base.length

function finalize(r::RawFileIter)
close(r.fname)
function finalize(s::RawFileState)
close(s.f)
end

function start(r::RawFileIter)
f = open(r.fname)
finalizer(r,finalize)
h = readheader(f)
batch_step = reduce(*,h.sizes[1:end-1])
total_length = batch_step*h.sizes[end]
batch_size = copy(h.sizes)
i = 0
return RawFileState(i,total_length,r.num_batch,batch_step,batch_size,f,h.typet)
s = RawFileState(i,total_length,r.num_batch,batch_step,batch_size,f,h.typet)
finalizer(s,finalize)
return s
end

function done(r::RawFileIter,state)
Expand Down

0 comments on commit a244510

Please sign in to comment.