[project @ 2000-04-11 20:44:17 by panne]
[ghc-hetmet.git] / ghc / lib / std / cbits / freeFile.c
index ffe5723..9e4c530 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  * (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.10 2000/04/11 20:44:18 panne Exp $
  *
  * Giving up files
  */
    before we *really* shut down (dumping stats etc.)
 */
 void
-freeStdFile(StgForeignPtr fp)
+freeStdFile(StgAddr fp)
 { return; }
 
 void
-freeStdFileObject(StgForeignPtr ptr)
+freeStdFileObject(StgAddr ptr)
 { 
   IOFileObject* fo = (IOFileObject*)ptr;
   int rc;
@@ -45,7 +45,7 @@ freeStdFileObject(StgForeignPtr ptr)
 }
 
 void
-freeFileObject(StgForeignPtr ptr)
+freeFileObject(StgAddr ptr)
 {
     /*
      * The finaliser for the file objects embedded in Handles. The RTS
@@ -65,7 +65,11 @@ freeFileObject(StgForeignPtr ptr)
          * (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) {
@@ -84,6 +88,11 @@ freeFileObject(StgForeignPtr ptr)
 #endif
     /* Error or no error, we don't care.. */
 
+    if ( fo->buf != NULL ) {
+       free(fo->buf);
+    }
+    free(fo);
+
     return;
 }