]> pd.if.org Git - pdclib/commitdiff
Synced fclose().
authorMartin Baute <solar@rootdirectory.de>
Sun, 27 Mar 2016 11:47:58 +0000 (13:47 +0200)
committerMartin Baute <solar@rootdirectory.de>
Sun, 27 Mar 2016 11:47:58 +0000 (13:47 +0200)
functions/stdio/fclose.c

index 7871833c0069c993ef50b89a0595bb4cb96ec1fa..b42cab3b14182f482afd1ad1c797437ba3fcacb1 100644 (file)
@@ -47,6 +47,11 @@ int fclose( struct _PDCLIB_file_t * stream )
             {
                 remove( stream->filename );
             }
             {
                 remove( stream->filename );
             }
+            /* Free user buffer (SetVBuf allocated) */
+            if ( stream->status & _PDCLIB_FREEBUFFER )
+            {
+                free( stream->buffer );
+            }
             /* Free stream */
             if ( ! ( stream->status & _PDCLIB_STATIC ) )
             {
             /* Free stream */
             if ( ! ( stream->status & _PDCLIB_STATIC ) )
             {
@@ -84,7 +89,7 @@ int main( void )
     TESTCASE( _PDCLIB_filelist == file2 );
     TESTCASE( fclose( file2 ) == 0 );
     TESTCASE( _PDCLIB_filelist == file1 );
     TESTCASE( _PDCLIB_filelist == file2 );
     TESTCASE( fclose( file2 ) == 0 );
     TESTCASE( _PDCLIB_filelist == file1 );
-    TESTCASE( ( file2 = fopen( testfile1, "w" ) ) != NULL );
+    TESTCASE( ( file2 = fopen( testfile2, "w" ) ) != NULL );
     TESTCASE( _PDCLIB_filelist == file2 );
     TESTCASE( fclose( file1 ) == 0 );
     TESTCASE( _PDCLIB_filelist == file2 );
     TESTCASE( _PDCLIB_filelist == file2 );
     TESTCASE( fclose( file1 ) == 0 );
     TESTCASE( _PDCLIB_filelist == file2 );