Last change
on this file since 337 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
600 bytes
|
Rev | Line | |
---|
[337] | 1 | #include "stdio_impl.h"
|
---|
| 2 | #include "libc.h"
|
---|
| 3 |
|
---|
| 4 | #ifndef __c2__
|
---|
| 5 | static void dummy(FILE *f) { }
|
---|
| 6 | weak_alias(dummy, __unlist_locked_file);
|
---|
| 7 | #else
|
---|
| 8 | extern void __unlist_locked_file(FILE *f);
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
| 11 | int fclose(FILE *f)
|
---|
| 12 | {
|
---|
| 13 | int r;
|
---|
| 14 | int perm;
|
---|
| 15 |
|
---|
| 16 | FLOCK(f);
|
---|
| 17 |
|
---|
| 18 | __unlist_locked_file(f);
|
---|
| 19 |
|
---|
| 20 | if (!(perm = f->flags & F_PERM)) {
|
---|
| 21 | FILE **head = __ofl_lock();
|
---|
| 22 | if (f->prev) f->prev->next = f->next;
|
---|
| 23 | if (f->next) f->next->prev = f->prev;
|
---|
| 24 | if (*head == f) *head = f->next;
|
---|
| 25 | __ofl_unlock();
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | r = fflush(f);
|
---|
| 29 | r |= f->close(f);
|
---|
| 30 |
|
---|
| 31 | if (f->getln_buf) free(f->getln_buf);
|
---|
| 32 | if (!perm) free(f);
|
---|
| 33 | else FUNLOCK(f);
|
---|
| 34 |
|
---|
| 35 | return r;
|
---|
| 36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.