From 1b0cdc8700d29ef018bf226d74b2b58b23bce91c Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 16 Jun 2015 07:11:19 +0000 Subject: refactor stdio open file list handling, move it out of global libc struct functions which open in-memory FILE stream variants all shared a tail with __fdopen, adding the FILE structure to stdio's open file list. replacing this common tail with a function call reduces code size and duplication of logic. the list is also partially encapsulated now. function signatures were chosen to facilitate tail call optimization and reduce the need for additional accessor functions. with these changes, static linked programs that do not use stdio no longer have an open file list at all. --- src/stdio/__stdio_exit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/stdio/__stdio_exit.c') diff --git a/src/stdio/__stdio_exit.c b/src/stdio/__stdio_exit.c index 716e5f73..191b4454 100644 --- a/src/stdio/__stdio_exit.c +++ b/src/stdio/__stdio_exit.c @@ -16,8 +16,7 @@ static void close_file(FILE *f) void __stdio_exit(void) { FILE *f; - OFLLOCK(); - for (f=libc.ofl_head; f; f=f->next) close_file(f); + for (f=*__ofl_lock(); f; f=f->next) close_file(f); close_file(__stdin_used); close_file(__stdout_used); } -- cgit v1.2.1