MCPcopy Create free account
hub / github.com/coreutils/coreutils / cache_round

Function cache_round

src/dd.c:999–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

997 Pass LEN == 0 to get the current remainder. */
998
999static off_t
1000cache_round (int fd, off_t len)
1001{
1002 static off_t i_pending, o_pending;
1003 off_t *pending = (fd == STDIN_FILENO ? &i_pending : &o_pending);
1004
1005 if (len)
1006 {
1007 intmax_t c_pending;
1008 if (ckd_add (&c_pending, *pending, len))
1009 c_pending = INTMAX_MAX;
1010 *pending = c_pending % IO_BUFSIZE;
1011 if (c_pending > *pending)
1012 len = c_pending - *pending;
1013 else
1014 len = 0;
1015 }
1016 else
1017 len = *pending;
1018
1019 return len;
1020}
1021
1022/* Discard the cache from the current offset of either
1023 STDIN_FILENO or STDOUT_FILENO.

Callers 1

invalidate_cacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected