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

Function xmlNewSaveCtxt

ThirdParty/libxml2/vtklibxml2/xmlsave.c:329–372  ·  view source on GitHub ↗

* xmlNewSaveCtxt: * * Create a new saving context * * Returns the new structure or NULL in case of error */

Source from the content-addressed store, hash-verified

327 * Returns the new structure or NULL in case of error
328 */
329static xmlSaveCtxtPtr
330xmlNewSaveCtxt(const char *encoding, int options)
331{
332 xmlSaveCtxtPtr ret;
333
334 ret = (xmlSaveCtxtPtr) xmlMalloc(sizeof(xmlSaveCtxt));
335 if (ret == NULL) {
336 xmlSaveErrMemory(NULL);
337 return ( NULL );
338 }
339 memset(ret, 0, sizeof(xmlSaveCtxt));
340
341 if (encoding != NULL) {
342 int res;
343
344 res = xmlOpenCharEncodingHandler(encoding, /* output */ 1,
345 &ret->handler);
346 if (res != XML_ERR_OK) {
347 xmlSaveErr(NULL, res, NULL, encoding);
348 xmlFreeSaveCtxt(ret);
349 return(NULL);
350 }
351 ret->encoding = xmlStrdup((const xmlChar *)encoding);
352 ret->escape = NULL;
353 }
354 xmlSaveCtxtInit(ret);
355
356 /*
357 * Use the options
358 */
359
360 /* Re-check this option as it may already have been set */
361 if ((ret->options & XML_SAVE_NO_EMPTY) && ! (options & XML_SAVE_NO_EMPTY)) {
362 options |= XML_SAVE_NO_EMPTY;
363 }
364
365 ret->options = options;
366 if (options & XML_SAVE_FORMAT)
367 ret->format = 1;
368 else if (options & XML_SAVE_WSNONSIG)
369 ret->format = 2;
370
371 return(ret);
372}
373
374/************************************************************************
375 * *

Callers 4

xmlSaveToFdFunction · 0.85
xmlSaveToFilenameFunction · 0.85
xmlSaveToBufferFunction · 0.85
xmlSaveToIOFunction · 0.85

Calls 6

xmlSaveErrMemoryFunction · 0.85
xmlSaveErrFunction · 0.85
xmlFreeSaveCtxtFunction · 0.85
xmlStrdupFunction · 0.85
xmlSaveCtxtInitFunction · 0.85

Tested by

no test coverage detected