* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid
[] = "@(#)fflush.c 5.1 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
/* Flush a single file, or (if fp is NULL) all files. */
return (_fwalk(__sflush
));
if ((fp
->_flags
& __SWR
) == 0) {
register unsigned char *p
;
if ((p
= fp
->_bf
._base
) == NULL
)
n
= fp
->_p
- p
; /* write this much */
* Set these immediately to avoid problems with longjmp and to allow
* exchange buffering (via setvbuf) in user write function.
fp
->_w
= t
& (__SLBF
|__SNBF
) ? 0 : fp
->_bf
._size
;
for (; n
> 0; n
-= t
, p
+= t
) {
t
= (*fp
->_write
)(fp
->_cookie
, (char *)p
, n
);