Home
       _allocbuf.c - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       _allocbuf.c (313B)
       ---
            1 #include <errno.h>
            2 #include <stdio.h>
            3 #include <stdlib.h>
            4 
            5 #include "../libc.h"
            6 
            7 int
            8 _allocbuf(FILE *fp)
            9 {
           10         unsigned char *bp;
           11 
           12         if ((bp = malloc(BUFSIZ)) == NULL) {
           13                 fp->flags |= _IOERR;
           14                 errno = ENOMEM;
           15                 return EOF;
           16         }
           17         fp->len = BUFSIZ;
           18         fp->rp = fp->wp = fp->buf = bp;
           19         fp->lp = bp + BUFSIZ;
           20 
           21         return 0;
           22 }