| 3036 | } |
| 3037 | |
| 3038 | static 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 | |
| 3054 | static int stdio_stream_buf_init(FILE *stream) |
| 3055 | { |
no test coverage detected