xref: /original-bsd/lib/libc/stdio/setbuf.c (revision 6c57d260)
1 /* @(#)setbuf.c	4.1 (Berkeley) 12/21/80 */
2 #include	<stdio.h>
3 
4 setbuf(iop, buf)
5 register struct _iobuf *iop;
6 char *buf;
7 {
8 	if (iop->_base != NULL && iop->_flag&_IOMYBUF)
9 		free(iop->_base);
10 	iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
11 	if ((iop->_base = buf) == NULL)
12 		iop->_flag |= _IONBF;
13 	else
14 		iop->_ptr = iop->_base;
15 	iop->_cnt = 0;
16 }
17