| OLD | NEW |
| 1 #include "stdio_impl.h" | 1 #include "stdio_impl.h" |
| 2 #include "libc.h" | 2 #include "libc.h" |
| 3 | 3 |
| 4 static void dummy(FILE *f) { } | 4 static void dummy(FILE* f) {} |
| 5 weak_alias(dummy, __unlist_locked_file); | 5 weak_alias(dummy, __unlist_locked_file); |
| 6 | 6 |
| 7 int fclose(FILE *f) | 7 int fclose(FILE* f) { |
| 8 { | 8 int r; |
| 9 » int r; | 9 int perm; |
| 10 » int perm; | |
| 11 » | |
| 12 » FLOCK(f); | |
| 13 | 10 |
| 14 » __unlist_locked_file(f); | 11 FLOCK(f); |
| 15 | 12 |
| 16 » if (!(perm = f->flags & F_PERM)) { | 13 __unlist_locked_file(f); |
| 17 » » FILE **head = __ofl_lock(); | |
| 18 » » if (f->prev) f->prev->next = f->next; | |
| 19 » » if (f->next) f->next->prev = f->prev; | |
| 20 » » if (*head == f) *head = f->next; | |
| 21 » » __ofl_unlock(); | |
| 22 » } | |
| 23 | 14 |
| 24 » r = fflush(f); | 15 if (!(perm = f->flags & F_PERM)) { |
| 25 » r |= f->close(f); | 16 FILE** head = __ofl_lock(); |
| 17 if (f->prev) |
| 18 f->prev->next = f->next; |
| 19 if (f->next) |
| 20 f->next->prev = f->prev; |
| 21 if (*head == f) |
| 22 *head = f->next; |
| 23 __ofl_unlock(); |
| 24 } |
| 26 | 25 |
| 27 » if (f->getln_buf) free(f->getln_buf); | 26 r = fflush(f); |
| 28 » if (!perm) free(f); | 27 r |= f->close(f); |
| 29 » else FUNLOCK(f); | |
| 30 | 28 |
| 31 » return r; | 29 if (f->getln_buf) |
| 30 free(f->getln_buf); |
| 31 if (!perm) |
| 32 free(f); |
| 33 else |
| 34 FUNLOCK(f); |
| 35 |
| 36 return r; |
| 32 } | 37 } |
| OLD | NEW |