* * * Allocation and deallocation * * * ************************************************************************/ * xmlSaveCtxtInit: * @ctxt: the saving context * * Initialize a saving context */
| 278 | * Initialize a saving context |
| 279 | */ |
| 280 | static void |
| 281 | xmlSaveCtxtInit(xmlSaveCtxtPtr ctxt) |
| 282 | { |
| 283 | int i; |
| 284 | int len; |
| 285 | |
| 286 | if (ctxt == NULL) return; |
| 287 | if ((ctxt->encoding == NULL) && (ctxt->escape == NULL)) |
| 288 | ctxt->escape = xmlEscapeEntities; |
| 289 | len = xmlStrlen((xmlChar *)xmlTreeIndentString); |
| 290 | if ((xmlTreeIndentString == NULL) || (len == 0)) { |
| 291 | memset(&ctxt->indent[0], 0, MAX_INDENT + 1); |
| 292 | } else { |
| 293 | ctxt->indent_size = len; |
| 294 | ctxt->indent_nr = MAX_INDENT / ctxt->indent_size; |
| 295 | for (i = 0;i < ctxt->indent_nr;i++) |
| 296 | memcpy(&ctxt->indent[i * ctxt->indent_size], xmlTreeIndentString, |
| 297 | ctxt->indent_size); |
| 298 | ctxt->indent[ctxt->indent_nr * ctxt->indent_size] = 0; |
| 299 | } |
| 300 | |
| 301 | if (xmlSaveNoEmptyTags) { |
| 302 | ctxt->options |= XML_SAVE_NO_EMPTY; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * xmlFreeSaveCtxt: |
no test coverage detected