projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
add proper fuxed-based locking for stdio
[oweals/musl.git]
/
src
/
stdio
/
fclose.c
1
#include "stdio_impl.h"
2
3
int fclose(FILE *f)
4
{
5
int r;
6
int perm = f->flags & F_PERM;
7
8
if (!perm) {
9
OFLLOCK();
10
if (f->prev) f->prev->next = f->next;
11
if (f->next) f->next->prev = f->prev;
12
if (libc.ofl_head == f) libc.ofl_head = f->next;
13
OFLUNLOCK();
14
}
15
16
r = fflush(f);
17
r |= f->close(f);
18
19
if (!perm) free(f);
20
21
return r;
22
}