#include <u.h>
#include <libc.h>
#include <bio.h>
Biobuf*
Bfdopen(int fd, int mode)
{
Biobuf *bp;
bp = malloc(sizeof(Biobuf));
if(bp == nil)
return nil;
if(Binits(bp, fd, mode, bp->b, sizeof(bp->b)) != 0){
free(bp);
return nil;
}
bp->flag = Bmagic; /* mark bp open & malloced */
setmalloctag(bp, getcallerpc(&fd));
return bp;
}
|