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

Function xmlBufferAdd

ThirdParty/libxml2/vtklibxml2/tree.c:7536–7567  ·  view source on GitHub ↗

* xmlBufferAdd: * @buf: the buffer to dump * @str: the #xmlChar string * @len: the number of #xmlChar to add * * Add a string range to an XML buffer. if len == -1, the length of * str is recomputed. * * Returns 0 successful, a positive error code number otherwise * and -1 in case of internal or API error. */

Source from the content-addressed store, hash-verified

7534 * and -1 in case of internal or API error.
7535 */
7536int
7537xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
7538 unsigned int needSize;
7539
7540 if ((str == NULL) || (buf == NULL)) {
7541 return -1;
7542 }
7543 if (len < -1) {
7544 return -1;
7545 }
7546 if (len == 0) return 0;
7547
7548 if (len < 0)
7549 len = xmlStrlen(str);
7550
7551 if (len < 0) return -1;
7552 if (len == 0) return 0;
7553
7554 /* Note that both buf->size and buf->use can be zero here. */
7555 if ((unsigned) len >= buf->size - buf->use) {
7556 if ((unsigned) len >= UINT_MAX - buf->use)
7557 return XML_ERR_NO_MEMORY;
7558 needSize = buf->use + len + 1;
7559 if (!xmlBufferResize(buf, needSize))
7560 return XML_ERR_NO_MEMORY;
7561 }
7562
7563 memmove(&buf->content[buf->use], str, len);
7564 buf->use += len;
7565 buf->content[buf->use] = 0;
7566 return 0;
7567}
7568
7569/**
7570 * xmlBufferAddHead:

Callers 5

xmlBufferCreateStaticFunction · 0.85
xmlBufferCatFunction · 0.85
xsdTestCaseFunction · 0.85
xmlBufferWriteFunction · 0.85

Calls 2

xmlStrlenFunction · 0.85
xmlBufferResizeFunction · 0.85

Tested by

no test coverage detected