Closed wkschwartz closed 7 years ago
Turns out calling c.fclose(outputFile)
actually does close the underlying file descriptor. The up shot is that we cannot close the *C.FILE
reference to OutputFile without closing the underlying file. It's better for the client to do this.
If a client passes a non-nil
OutputFile *os.File
to the Pigosat constructor, the constructor opens a*C.FILE
and leaves it open, passing it to Picosat. Since we create the*C.FILE
in the constructor, we should close it in the destructor. This may require holding onto the*C.FILE
in thePigosat
object (in a private data member), to be closed inPigosat.delete
. Make sure to set this data member to nil whendelete
is done with it.We should test that closing the
*C.FILE
does not close the underlying*os.File
. From what I can tell from the manpage forfclose
,fclose(*FILE)
only dissociates the particular instance of*FILE
from the underlying file descriptor, so closing one*FILE
doesn't close the descriptor for other open instances of that descriptor.