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

Function buffer_or_output

src/relpath.c:65–83  ·  view source on GitHub ↗

Either output STR to stdout or if *PBUF is not null then append STR to *PBUF and update *PBUF to point to the end of the buffer and adjust *PLEN to reflect the remaining space. Return TRUE on failure. */

Source from the content-addressed store, hash-verified

63 and adjust *PLEN to reflect the remaining space.
64 Return TRUE on failure. */
65static bool
66buffer_or_output (char const *str, char **pbuf, size_t *plen)
67{
68 if (*pbuf)
69 {
70 size_t slen = strlen (str);
71 if (slen >= *plen)
72 return true;
73 memcpy (*pbuf, str, slen + 1);
74 *pbuf += slen;
75 *plen -= slen;
76 }
77 else
78 {
79 fputs (str, stdout);
80 }
81
82 return false;
83}
84
85/* Output the relative representation if possible.
86 If BUF is non-null, write to that buffer rather than to stdout. */

Callers 1

relpathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected