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

Function xmlParserAddNodeInfo

ThirdParty/libxml2/vtklibxml2/parserInternals.c:2736–2793  ·  view source on GitHub ↗

* xmlParserAddNodeInfo: * @ctxt: an XML parser context * @info: a node info sequence pointer * * DEPRECATED: Don't use. * * Insert node info record into the sorted sequence */

Source from the content-addressed store, hash-verified

2734 * Insert node info record into the sorted sequence
2735 */
2736void
2737xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
2738 xmlParserNodeInfoPtr info)
2739{
2740 unsigned long pos;
2741
2742 if ((ctxt == NULL) || (info == NULL)) return;
2743
2744 /* Find pos and check to see if node is already in the sequence */
2745 pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
2746 info->node);
2747
2748 if ((pos < ctxt->node_seq.length) &&
2749 (ctxt->node_seq.buffer != NULL) &&
2750 (ctxt->node_seq.buffer[pos].node == info->node)) {
2751 ctxt->node_seq.buffer[pos] = *info;
2752 }
2753
2754 /* Otherwise, we need to add new node to buffer */
2755 else {
2756 if ((ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) ||
2757 (ctxt->node_seq.buffer == NULL)) {
2758 xmlParserNodeInfo *tmp_buffer;
2759 unsigned int byte_size;
2760
2761 if (ctxt->node_seq.maximum == 0)
2762 ctxt->node_seq.maximum = 2;
2763 byte_size = (sizeof(*ctxt->node_seq.buffer) *
2764 (2 * ctxt->node_seq.maximum));
2765
2766 if (ctxt->node_seq.buffer == NULL)
2767 tmp_buffer = (xmlParserNodeInfo *) xmlMalloc(byte_size);
2768 else
2769 tmp_buffer =
2770 (xmlParserNodeInfo *) xmlRealloc(ctxt->node_seq.buffer,
2771 byte_size);
2772
2773 if (tmp_buffer == NULL) {
2774 xmlCtxtErrMemory(ctxt);
2775 return;
2776 }
2777 ctxt->node_seq.buffer = tmp_buffer;
2778 ctxt->node_seq.maximum *= 2;
2779 }
2780
2781 /* If position is not at end, move elements out of the way */
2782 if (pos != ctxt->node_seq.length) {
2783 unsigned long i;
2784
2785 for (i = ctxt->node_seq.length; i > pos; i--)
2786 ctxt->node_seq.buffer[i] = ctxt->node_seq.buffer[i - 1];
2787 }
2788
2789 /* Copy element and increase length */
2790 ctxt->node_seq.buffer[pos] = *info;
2791 ctxt->node_seq.length++;
2792 }
2793}

Callers 3

htmlParseElementFunction · 0.85
xmlParseElementStartFunction · 0.85

Calls 2

xmlCtxtErrMemoryFunction · 0.85

Tested by

no test coverage detected