1240075Sdes/*
2224638Sbrooks * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
357429Smarkm * Distributed under the terms of the MIT License.
457429Smarkm */
557429Smarkm
657429Smarkm#include <libio.h>
757429Smarkm#include <stdio_ext.h>
857429Smarkm#include <stdlib.h>
957429Smarkm
1060573Skris
1165668Skrisint
1265668Skrisfpurge(FILE* stream)
1365668Skris{
1465668Skris	// purge read and write buffers
1565668Skris	stream->_IO_read_end = stream->_IO_read_ptr;
1665668Skris	stream->_IO_write_ptr = stream->_IO_write_base;
1760573Skris
1892559Sdes	// free ungetc buffer
1965668Skris	if (stream->_IO_save_base != NULL) {
2065668Skris		free(stream->_IO_save_base);
2165668Skris		stream->_IO_save_base = NULL;
2265668Skris	}
2365668Skris
2465668Skris	return 0;
2565668Skris}
2665668Skris
2765668Skris
2865668Skrisvoid
2965668Skris__fpurge(FILE* stream)
3065668Skris{
3165668Skris	fpurge(stream);
3265668Skris}
3365668Skris