/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: closeFile.c,v 1.8 2000/03/14 01:52:25 sof Exp $
+ * $Id: closeFile.c,v 1.9 2000/03/28 08:49:56 simonmar Exp $
*
* hClose Runtime Support
*/
}
+ /* Free the buffer straight away. We can't free the file object
+ * itself until the finalizer runs.
+ */
+ if ( fo->buf != NULL ) {
+ free(fo->buf);
+ fo->buf = NULL;
+ }
+
/* Closing file descriptors that refer to standard channels
is problematic, so we back off from doing this by default,
just closing them at the Handle level. If you insist on
}
}
}
+
fo->fd = -1;
+
return 0;
}
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: freeFile.c,v 1.8 1999/11/26 16:25:56 simonmar Exp $
+ * $Id: freeFile.c,v 1.9 2000/03/28 08:49:56 simonmar Exp $
*
* Giving up files
*/
* (via closeFile()), we will have given
* up our process lock, so we break off and just return.
*/
- return;
+ if ( fo->buf != NULL ) {
+ free(fo->buf);
+ }
+ free(fo);
+ return;
}
if (fo->buf != NULL && fo->bufWPtr > 0) {
#endif
/* Error or no error, we don't care.. */
+ if ( fo->buf != NULL ) {
+ free(fo->buf);
+ }
+ free(fo);
+
return;
}