1 /* @(#)setbuffer.c 4.1 (Berkeley) 10/05/82 */ 2 #include <stdio.h> 3 4 setbuffer(iop, buf, size) 5 register struct _iobuf *iop; 6 char *buf; 7 int size; 8 { 9 if (iop->_base != NULL && iop->_flag&_IOMYBUF) 10 free(iop->_base); 11 iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); 12 if ((iop->_base = buf) == NULL) { 13 iop->_flag |= _IONBF; 14 iop->_bufsiz = NULL; 15 } else { 16 iop->_ptr = iop->_base; 17 iop->_bufsiz = size; 18 } 19 iop->_cnt = 0; 20 } 21