home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
GETBUF.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
783b
|
31 lines
/* from the dLibs getbuf.c */
#include <stdio.h>
#include <stdlib.h>
extern size_t __DEFAULT_BUFSIZ__;
void _getbuf(fp) /* allocate a buffer for a stream */
register FILE *fp;
{
unsigned int f = fp->_flag;
if(f & _IOLBF)
fp->_bsiz = (__DEFAULT_BUFSIZ__ < BUFSIZ) ? __DEFAULT_BUFSIZ__ :
BUFSIZ;
else
fp->_bsiz = __DEFAULT_BUFSIZ__;
if((f & _IONBF) /* risky!! but works ok with gnu.may change */
|| ((fp->_base = malloc((size_t)fp->_bsiz)) == NULL) ) {
fp->_flag &= ~(_IOFBF | _IOLBF | _IONBF);
fp->_flag |= _IONBF;
fp->_base = &(fp->_ch); /* use tiny buffer */
fp->_bsiz = 1;
}
else
fp->_flag |= _IOMYBUF; /* use big buffer */
fp->_ptr = fp->_base;
fp->_cnt = 0; /* start out with an empty buffer */
}