From c96362fb839b9b6c68601599d0ec90c8aaca53f3 Mon Sep 17 00:00:00 2001 From: bumbread Date: Tue, 26 Jul 2022 04:07:41 +1100 Subject: [PATCH] stdio.h: fclose --- src/_win/stdio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/_win/stdio.c b/src/_win/stdio.c index 3e19698..b599dd4 100644 --- a/src/_win/stdio.c +++ b/src/_win/stdio.c @@ -239,6 +239,15 @@ FILE *tmpfile(void) { } int fclose(FILE *stream) { + if(fflush(stream) == EOF) { + return EOF; + } + if(stream->buffer.is_internal) { + free(stream->buffer.data); + } + if(!CloseHandle(stream->handle)) { + return EOF; + } return 0; }