From: simonmar Date: Fri, 14 Apr 2000 12:49:39 +0000 (+0000) Subject: [project @ 2000-04-14 12:49:39 by simonmar] X-Git-Tag: Approximately_9120_patches~4699 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=5a21d20b0f25de3d829de90d219cb66855f91d58;p=ghc-hetmet.git [project @ 2000-04-14 12:49:39 by simonmar] Free the spare buffers immediately we hClose a file handle. --- diff --git a/ghc/lib/std/PrelHandle.lhs b/ghc/lib/std/PrelHandle.lhs index 8d02b32..1731cbf 100644 --- a/ghc/lib/std/PrelHandle.lhs +++ b/ghc/lib/std/PrelHandle.lhs @@ -392,11 +392,16 @@ hClose handle = is finalized. (we overwrite the file ptr in the underlying FileObject with a NULL as part of closeFile()) -} - if rc == (0::Int) - then return (handle_{ haType__ = ClosedHandle, - haFO__ = nullFile__ }) - else constructErrorAndFail "hClose" + if (rc /= 0) + then constructErrorAndFail "hClose" + + -- free the spare buffers (except the handle buffer) + -- associated with this handle. + else do freeBuffers (haBuffers__ handle_) + return (handle_{ haType__ = ClosedHandle, + haFO__ = nullFile__, + haBuffers__ = [] }) \end{code} Computation $hClose hdl$ makes handle {\em hdl} closed. Before the