#include "file.h" #include #include #include #include #include #include int fclose(struct __opaque_file *stream) { if (stream->f_fd < 0) { return __set_errno(EBADF); } close(stream->f_fd); if (stream->f_buf.buf_ptr) { free(stream->f_buf.buf_ptr); } if (!(stream->f_flags & FILE_STATIC)) { free(stream); } return SUCCESS; }