xref: /original-bsd/lib/libc/stdio/setbuf.c (revision 957a0273)
1 /* @(#)setbuf.c	4.2 (Berkeley) 10/05/82 */
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 		iop->_bufsiz = NULL;
14 	} else {
15 		iop->_ptr = iop->_base;
16 		iop->_bufsiz = BUFSIZ;
17 	}
18 	iop->_cnt = 0;
19 }
20