From 2b10f10cde517fede45e620a0c3a7948d90afd7b Mon Sep 17 00:00:00 2001 From: Martin Baute Date: Sun, 27 Mar 2016 13:47:58 +0200 Subject: [PATCH] Synced fclose(). --- functions/stdio/fclose.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 ); -- 2.40.0