/* As a side effect, we set __SOPT or __SNPT (en/dis-able fseek optimisation) right after the fstat() that finds the buffer size.  */
void __smakebuf(FILE *fp)
/* As a side effect, we set __SOPT or __SNPT (en/dis-able fseek optimisation) right after the fstat() that finds the buffer size.  */
void __smakebuf(FILE *fp)
{
	register void *p;
	register int flags;
	size_t size;
	int couldbetty;
	if (fp->_flags & __SNBF) {
		fp->_bf._base = fp->_p = fp->_nbuf;
		fp->_bf._size = 1;
		return;
	}
	flags = __swhatbuf(fp, &size, &couldbetty);
	if ((p = malloc(size)) == NULL) {
		fp->_flags |= __SNBF;
		fp->_bf._base = fp->_p = fp->_nbuf;
		fp->_bf._size = 1;
		return;
	}
	__cleanup = _cleanup;
	flags |= __SMBF;
	fp->_bf._base = fp->_p = p;
	fp->_bf._size = size;
	if (couldbetty && isatty(fp->_file))
		flags |= __SLBF;
	fp->_flags |= flags;
}