From: Martin Baute Date: Sun, 27 Mar 2016 11:47:58 +0000 (+0200) Subject: Synced fclose(). X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=2b10f10cde517fede45e620a0c3a7948d90afd7b Synced fclose(). --- diff --git a/functions/stdio/fclose.c b/functions/stdio/fclose.c index 7871833..b42cab3 100644 --- a/functions/stdio/fclose.c +++ b/functions/stdio/fclose.c @@ -47,6 +47,11 @@ int fclose( struct _PDCLIB_file_t * stream ) { remove( stream->filename ); } + /* Free user buffer (SetVBuf allocated) */ + if ( stream->status & _PDCLIB_FREEBUFFER ) + { + free( stream->buffer ); + } /* 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( ( file2 = fopen( testfile1, "w" ) ) != NULL ); + TESTCASE( ( file2 = fopen( testfile2, "w" ) ) != NULL ); TESTCASE( _PDCLIB_filelist == file2 ); TESTCASE( fclose( file1 ) == 0 ); TESTCASE( _PDCLIB_filelist == file2 );