MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_strndup

Function xo_strndup

tools/libxo/libxo/libxo.c:2476–2489  ·  view source on GitHub ↗

* strndup with a twist: len < 0 means len = strlen(str) */

Source from the content-addressed store, hash-verified

2474 * strndup with a twist: len < 0 means len = strlen(str)
2475 */
2476static char *
2477xo_strndup (const char *str, ssize_t len)
2478{
2479 if (len < 0)
2480 len = strlen(str);
2481
2482 char *cp = xo_realloc(NULL, len + 1);
2483 if (cp) {
2484 memcpy(cp, str, len);
2485 cp[len] = '\0';
2486 }
2487
2488 return cp;
2489}
2490
2491/**
2492 * Record a leading prefix for the XPath we generate. This allows the

Callers 5

xo_set_leading_xpathFunction · 0.85
xo_set_gettext_domainFunction · 0.85
xo_gettext_build_formatFunction · 0.85
xo_depth_changeFunction · 0.85
xo_set_version_hFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected