blob: 5d66830db620c5b0efed2e54476fc28eb93c1552 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html
// FIXME: Do some actual error checking.
int fclose(FILE *stream) {
if (stream) {
if (stream->fflush) {
stream->fflush(stream);
}
if (stream->has_control_over_the_fd) {
close(stream->fd);
}
free(stream->cookie);
}
free(stream);
return 0;
}
|