* 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. */
| 4487 | * Returns a new xmlChar buffer with the data or NULL on error. This buffer must be freed. |
| 4488 | */ |
| 4489 | static xmlChar * |
| 4490 | xmlTextWriterVSprintf(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: |
no test coverage detected