MCPcopy Create free account
hub / github.com/GJDuck/e9patch / stdio_stream_alloc

Function stdio_stream_alloc

examples/stdlib.c:3038–3052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3036}
3037
3038static FILE *stdio_stream_alloc(int fd, bool r, bool w, int mode)
3039{
3040 FILE *stream = (FILE *)malloc(sizeof(struct stdio_stream_s));
3041 if (stream == NULL)
3042 return NULL;
3043 memset(stream, 0, sizeof(*stream));
3044 stream->flags = (r? STDIO_FLAG_READ: 0) |
3045 (w? STDIO_FLAG_WRITE: 0) |
3046 (mode == _IONBF? STDIO_FLAG_NO_BUF: 0);
3047 stream->eol = (mode == _IOLBF? '\n': EOF);
3048 stream->unget = EOF;
3049 stream->bufsiz = BUFSIZ;
3050 stream->fd = fd;
3051 return stream;
3052}
3053
3054static int stdio_stream_buf_init(FILE *stream)
3055{

Callers 3

fdopenFunction · 0.85
fopenFunction · 0.85
stdio_get_streamFunction · 0.85

Calls 2

mallocFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected