Mon, 03 Apr 2023 19:48:00 +0200
simplify cx_stream_ncopy()
src/utils.c | file | annotate | diff | comparison | revisions |
--- a/src/utils.c Mon Apr 03 19:20:30 2023 +0200 +++ b/src/utils.c Mon Apr 03 19:48:00 2023 +0200 @@ -84,27 +84,9 @@ cx_write_func wfnc, size_t n ) { - if (n == 0) { - return 0; - } - - const size_t bufsize = CX_STREAM_COPY_BUF_SIZE; - char lbuf[bufsize]; - size_t ncp = 0; - - size_t r; - size_t rn = bufsize > n ? n : bufsize; - while ((r = rfnc(lbuf, 1, rn, src)) != 0) { - r = wfnc(lbuf, 1, r, dest); - ncp += r; - n -= r; - rn = bufsize > n ? n : bufsize; - if (r == 0 || n == 0) { - break; - } - } - - return ncp; + char buf[CX_STREAM_COPY_BUF_SIZE]; + return cx_stream_bncopy(src, dest, rfnc, wfnc, + buf, CX_STREAM_COPY_BUF_SIZE, n); } #ifndef CX_SZMUL_BUILTIN