aboutsummaryrefslogtreecommitdiffstats
path: root/usr/klibc/stdio/fclose.c
blob: 756de4329d7770dae63cb961b42202d6b4b23f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * fclose.c
 */

#include "stdioint.h"

int fclose(FILE *file)
{
	struct _IO_file_pvt *f = stdio_pvt(file);
	int rv;

	fflush(file);

	rv = close(f->pub._IO_fileno);

	/* Remove from linked list */
	f->next->prev = f->prev;
	f->prev->next = f->next;

	free(f);
	return rv;
}