summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fclose.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-03 15:08:45 +0200
committerAnton Kling <anton@kling.gg>2024-10-03 15:08:45 +0200
commit226d861c9ebb7f09f95665d07d9ab5c6b7ed7d6f (patch)
treed900c3437d3d65ee7bd88474586dc6dd947b14ce /userland/libc/stdio/fclose.c
parent64b0b49a1f23da9faa680f8158cb8a12cd4d118c (diff)
libc: small changes
Diffstat (limited to 'userland/libc/stdio/fclose.c')
-rw-r--r--userland/libc/stdio/fclose.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/userland/libc/stdio/fclose.c b/userland/libc/stdio/fclose.c
index 01bdb22..eb92387 100644
--- a/userland/libc/stdio/fclose.c
+++ b/userland/libc/stdio/fclose.c
@@ -4,8 +4,12 @@
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html
// FIXME: Do some actual error checking.
int fclose(FILE *stream) {
- if (stream)
+ if (stream) {
+ if (stream->fflush) {
+ stream->fflush(stream);
+ }
free(stream->cookie);
+ }
free(stream);
return 0;
}