shithub: scc

ref: 19f4d62e77c2b66116a48c6605f2cc9f239e53b0
dir: /src/libc/stdio/_allocbuf.c/

View raw version
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

#include "../libc.h"

int
_allocbuf(FILE *fp)
{
	char *bp;

	if ((bp = malloc(BUFSIZ)) == NULL) {
		fp->flags |= _IOERR;
		errno = ENOMEM;
		return EOF;
	}
	fp->len = BUFSIZ;
	fp->rp = fp->wp = fp->buf = bp;
	fp->lp = bp + BUFSIZ;

	return 0;
}