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

Function xmlCharEncCloseFunc

ThirdParty/libxml2/vtklibxml2/encoding.c:2651–2711  ·  view source on GitHub ↗

* xmlCharEncCloseFunc: * @handler: char encoding transformation data structure * * Generic front-end for encoding handler close function * * Returns 0 if success, or -1 in case of error */

Source from the content-addressed store, hash-verified

2649 * Returns 0 if success, or -1 in case of error
2650 */
2651int
2652xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
2653 int ret = 0;
2654 int tofree = 0;
2655 int i = 0;
2656
2657 if (handler == NULL) return(-1);
2658
2659 for (i = 0; i < (int) NUM_DEFAULT_HANDLERS; i++) {
2660 if (handler == &defaultHandlers[i])
2661 return(0);
2662 }
2663
2664 if (handlers != NULL) {
2665 for (i = 0;i < nbCharEncodingHandler; i++) {
2666 if (handler == handlers[i])
2667 return(0);
2668 }
2669 }
2670#ifdef LIBXML_ICONV_ENABLED
2671 /*
2672 * Iconv handlers can be used only once, free the whole block.
2673 * and the associated icon resources.
2674 */
2675 if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
2676 tofree = 1;
2677 if (handler->iconv_out != NULL) {
2678 if (iconv_close(handler->iconv_out))
2679 ret = -1;
2680 handler->iconv_out = NULL;
2681 }
2682 if (handler->iconv_in != NULL) {
2683 if (iconv_close(handler->iconv_in))
2684 ret = -1;
2685 handler->iconv_in = NULL;
2686 }
2687 }
2688#endif /* LIBXML_ICONV_ENABLED */
2689#ifdef LIBXML_ICU_ENABLED
2690 if ((handler->uconv_out != NULL) || (handler->uconv_in != NULL)) {
2691 tofree = 1;
2692 if (handler->uconv_out != NULL) {
2693 closeIcuConverter(handler->uconv_out);
2694 handler->uconv_out = NULL;
2695 }
2696 if (handler->uconv_in != NULL) {
2697 closeIcuConverter(handler->uconv_in);
2698 handler->uconv_in = NULL;
2699 }
2700 }
2701#endif
2702 if (tofree) {
2703 /* free up only dynamic handlers iconv/uconv */
2704 if (handler->name != NULL)
2705 xmlFree(handler->name);
2706 handler->name = NULL;
2707 xmlFree(handler);
2708 }

Callers 15

xmlDetectEBCDICFunction · 0.85
xmlSwitchInputEncodingFunction · 0.85
htmlNodeDumpFileFormatFunction · 0.85
htmlDocDumpMemoryFormatFunction · 0.85
htmlDocDumpFunction · 0.85
htmlSaveFileFunction · 0.85
htmlSaveFileFormatFunction · 0.85
xmlSaveSwitchEncodingFunction · 0.85
xmlSaveClearEncodingFunction · 0.85
xmlSaveToFdFunction · 0.85
xmlSaveToFilenameFunction · 0.85
xmlSaveToBufferFunction · 0.85

Calls 1

closeIcuConverterFunction · 0.85

Tested by 1

launchTestsFunction · 0.68