MCPcopy Create free account
hub / github.com/catboost/catboost / strfcpy

Function strfcpy

util/generic/strfcpy.cpp:31–50  ·  view source on GitHub ↗

* Copy string src to buffer dst of size dsize. At most dsize-1 * chars will be copied. Always NUL terminates (unless dsize == 0). */

Source from the content-addressed store, hash-verified

29 * chars will be copied. Always NUL terminates (unless dsize == 0).
30 */
31void strfcpy(char* dst, const char* src, size_t dsize)
32{
33 size_t nleft = dsize;
34
35 /* Copy as many bytes as will fit. */
36 if (nleft != 0) {
37 while (--nleft != 0) {
38 if ((*dst++ = *src++) == '\0') {
39 break;
40 }
41 }
42 }
43
44 /* Not enough room in dst, add NUL */
45 if (nleft == 0) {
46 if (dsize != 0) {
47 *dst = '\0'; /* NUL-terminate dst */
48 }
49 }
50}

Callers 2

LastSystemErrorTextFunction · 0.85
CopyToFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected