libroot: Clean up fpurge implementation.
* Take it from upstream glibc 2.15, much closer to the version we use. * Drop fpurge from stdio.h, it's nonstandard. Keep it around for ABI compatibility for now (BeOS didn't have it.) __fpurge is left in stdio_ext.h.
This commit is contained in:
@@ -120,7 +120,6 @@ extern FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t
|
||||
/* file I/O */
|
||||
extern int fflush(FILE *stream);
|
||||
extern int fflush_unlocked(FILE *stream);
|
||||
extern int fpurge(FILE *stream);
|
||||
|
||||
extern int fgetpos(FILE *stream, fpos_t *position);
|
||||
extern int fsetpos(FILE *stream, const fpos_t *position);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000-2014 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -12,9 +12,11 @@
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio_ext.h>
|
||||
#include "libioP.h"
|
||||
|
||||
@@ -25,7 +27,7 @@ __fpurge (FILE *fp)
|
||||
{
|
||||
/* Wide-char stream. */
|
||||
if (_IO_in_backup (fp))
|
||||
_IO_free_wbackup_area (fp);
|
||||
INTUSE(_IO_free_wbackup_area) (fp);
|
||||
|
||||
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
|
||||
fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
|
||||
@@ -34,16 +36,23 @@ __fpurge (FILE *fp)
|
||||
{
|
||||
/* Byte stream. */
|
||||
if (_IO_in_backup (fp))
|
||||
_IO_free_backup_area (fp);
|
||||
INTUSE(_IO_free_backup_area) (fp);
|
||||
|
||||
fp->_IO_read_end = fp->_IO_read_ptr;
|
||||
fp->_IO_write_ptr = fp->_IO_write_base;
|
||||
}
|
||||
|
||||
/* Avoid memory leak when there is an active ungetc buffer. */
|
||||
if (fp->_IO_save_base != NULL)
|
||||
{
|
||||
free (fp->_IO_save_base);
|
||||
fp->_IO_save_base = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
fpurge(FILE* stream)
|
||||
{
|
||||
__fpurge(stream);
|
||||
return 0;
|
||||
__fpurge(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user