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

Function xmlTextWriterVSprintf

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:4489–4522  ·  view source on GitHub ↗

* xmlTextWriterVSprintf: * @format: see printf * @argptr: pointer to the first member of the variable argument list. * * Utility function for formatted output * * Returns a new xmlChar buffer with the data or NULL on error. This buffer must be freed. */

Source from the content-addressed store, hash-verified

4487 * Returns a new xmlChar buffer with the data or NULL on error. This buffer must be freed.
4488 */
4489static xmlChar *
4490xmlTextWriterVSprintf(const char *format, va_list argptr)
4491{
4492 int size;
4493 int count;
4494 xmlChar *buf;
4495 va_list locarg;
4496
4497 size = BUFSIZ;
4498 buf = (xmlChar *) xmlMalloc(size);
4499 if (buf == NULL) {
4500 xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
4501 "xmlTextWriterVSprintf : out of memory!\n");
4502 return NULL;
4503 }
4504
4505 va_copy(locarg, argptr);
4506 while (((count = vsnprintf((char *) buf, size, format, locarg)) < 0)
4507 || (count == size - 1) || (count == size) || (count > size)) {
4508 va_end(locarg);
4509 xmlFree(buf);
4510 size += BUFSIZ;
4511 buf = (xmlChar *) xmlMalloc(size);
4512 if (buf == NULL) {
4513 xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
4514 "xmlTextWriterVSprintf : out of memory!\n");
4515 return NULL;
4516 }
4517 va_copy(locarg, argptr);
4518 }
4519 va_end(locarg);
4520
4521 return buf;
4522}
4523
4524/**
4525 * xmlTextWriterStartDocumentCallback:

Calls 1

xmlWriterErrMsgFunction · 0.85

Tested by

no test coverage detected