MCPcopy Create free account
hub / github.com/Kitware/VTK / path_append

Function path_append

ThirdParty/libproj/vtklibproj/src/4D_api.cpp:1549–1596  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

1547
1548/*****************************************************************************/
1549static char *path_append (char *buf, const char *app, size_t *buf_size) {
1550/******************************************************************************
1551 Helper for proj_info() below. Append app to buf, separated by a
1552 semicolon. Also handle allocation of longer buffer if needed.
1553
1554 Returns buffer and adjusts *buf_size through provided pointer arg.
1555******************************************************************************/
1556 char *p;
1557 size_t len, applen = 0, buflen = 0;
1558#ifdef _WIN32
1559 const char *delim = ";";
1560#else
1561 const char *delim = ":";
1562#endif
1563
1564 /* Nothing to do? */
1565 if (nullptr == app)
1566 return buf;
1567 applen = strlen (app);
1568 if (0 == applen)
1569 return buf;
1570
1571 /* Start checking whether buf is long enough */
1572 if (nullptr != buf)
1573 buflen = strlen (buf);
1574 len = buflen+applen+strlen (delim) + 1;
1575
1576 /* "pj_realloc", so to speak */
1577 if (*buf_size < len) {
1578 p = static_cast<char*>(calloc (2 * len, sizeof (char)));
1579 if (nullptr==p) {
1580 free (buf);
1581 return nullptr;
1582 }
1583 *buf_size = 2 * len;
1584 if (buf != nullptr)
1585 strcpy (p, buf);
1586 free (buf);
1587 buf = p;
1588 }
1589 assert(buf);
1590
1591 /* Only append a delimiter if something's already there */
1592 if (0 != buflen)
1593 strcat (buf, delim);
1594 strcat (buf, app);
1595 return buf;
1596}
1597
1598static const char *empty = {""};
1599static char version[64] = {""};

Callers 1

proj_infoFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected