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

Function xmlStrncatNew

ThirdParty/libxml2/vtklibxml2/xmlstring.c:492–517  ·  view source on GitHub ↗

* xmlStrncatNew: * @str1: first xmlChar string * @str2: second xmlChar string * @len: the len of @str2 or < 0 * * same as xmlStrncat, but creates a new string. The original * two strings are not freed. If @len is < 0 then the length * will be calculated automatically. * * Returns a new xmlChar * or NULL */

Source from the content-addressed store, hash-verified

490 * Returns a new xmlChar * or NULL
491 */
492xmlChar *
493xmlStrncatNew(const xmlChar *str1, const xmlChar *str2, int len) {
494 int size;
495 xmlChar *ret;
496
497 if (len < 0) {
498 len = xmlStrlen(str2);
499 if (len < 0)
500 return(NULL);
501 }
502 if (str1 == NULL)
503 return(xmlStrndup(str2, len));
504 if ((str2 == NULL) || (len == 0))
505 return(xmlStrdup(str1));
506
507 size = xmlStrlen(str1);
508 if ((size < 0) || (size > INT_MAX - len))
509 return(NULL);
510 ret = (xmlChar *) xmlMalloc((size_t) size + len + 1);
511 if (ret == NULL)
512 return(NULL);
513 memcpy(ret, str1, size);
514 memcpy(&ret[size], str2, len);
515 ret[size + len] = 0;
516 return(ret);
517}
518
519/**
520 * xmlStrcat:

Callers 3

xmlTextAddContentFunction · 0.85
xmlInsertNodeFunction · 0.85
xmlSchemaVPushTextFunction · 0.85

Calls 3

xmlStrlenFunction · 0.85
xmlStrndupFunction · 0.85
xmlStrdupFunction · 0.85

Tested by

no test coverage detected