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

Function fwrite_unlocked

examples/stdlib.c:3555–3586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3553}
3554
3555static size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb,
3556 FILE *stream)
3557{
3558 if (stdio_stream_write_init(stream) < 0)
3559 return 0;
3560 size *= nmemb;
3561 if (size == 0)
3562 return 0;
3563 const char *ptr8 = (const char *)ptr;
3564 if (stream->write_ptr == NULL)
3565 {
3566 if (stdio_stream_write_buf(stream, ptr8, ptr8 + size) < 0)
3567 return 0;
3568 return nmemb;
3569 }
3570 bool flush = false;
3571 for (size_t i = 0; i < size; i++)
3572 {
3573 *stream->write_ptr++ = ptr8[i];
3574 if (stream->write_ptr >= stream->write_end)
3575 {
3576 if (stdio_stream_write(stream) < 0)
3577 return 0;
3578 flush = false;
3579 }
3580 else if ((int)(unsigned char)ptr8[i] == stream->eol)
3581 flush = true;
3582 }
3583 if (flush && stdio_stream_write(stream) < 0)
3584 return 0;
3585 return nmemb;
3586}
3587
3588static size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
3589{

Callers 1

fwriteFunction · 0.85

Calls 3

stdio_stream_write_initFunction · 0.85
stdio_stream_write_bufFunction · 0.85
stdio_stream_writeFunction · 0.85

Tested by

no test coverage detected