mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
336 B
22 lines
336 B
#include "stdio_impl.h"
|
|
|
|
int fclose(FILE *f)
|
|
{
|
|
int r;
|
|
int perm = f->flags & F_PERM;
|
|
|
|
if (!perm) {
|
|
OFLLOCK();
|
|
if (f->prev) f->prev->next = f->next;
|
|
if (f->next) f->next->prev = f->prev;
|
|
if (libc.ofl_head == f) libc.ofl_head = f->next;
|
|
OFLUNLOCK();
|
|
}
|
|
|
|
r = fflush(f);
|
|
r |= f->close(f);
|
|
|
|
if (!perm) free(f);
|
|
|
|
return r;
|
|
}
|
|
|