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

Function xmlXPathEqualNodeSets

ThirdParty/libxml2/vtklibxml2/xpath.c:5830–5935  ·  view source on GitHub ↗

* xmlXPathEqualNodeSets: * @arg1: first nodeset object argument * @arg2: second nodeset object argument * @neq: flag to show whether to test '=' (0) or '!=' (1) * * Implement the equal / not equal operation on XPath nodesets: * @arg1 == @arg2 or @arg1 != @arg2 * If both objects to be compared are node-sets, then the comparison * will be true if and only if there is a node in the firs

Source from the content-addressed store, hash-verified

5828 * Returns 0 or 1 depending on the results of the test.
5829 */
5830static int
5831xmlXPathEqualNodeSets(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr arg1,
5832 xmlXPathObjectPtr arg2, int neq) {
5833 int i, j;
5834 unsigned int *hashs1;
5835 unsigned int *hashs2;
5836 xmlChar **values1;
5837 xmlChar **values2;
5838 int ret = 0;
5839 xmlNodeSetPtr ns1;
5840 xmlNodeSetPtr ns2;
5841
5842 if ((arg1 == NULL) ||
5843 ((arg1->type != XPATH_NODESET) && (arg1->type != XPATH_XSLT_TREE)))
5844 return(0);
5845 if ((arg2 == NULL) ||
5846 ((arg2->type != XPATH_NODESET) && (arg2->type != XPATH_XSLT_TREE)))
5847 return(0);
5848
5849 ns1 = arg1->nodesetval;
5850 ns2 = arg2->nodesetval;
5851
5852 if ((ns1 == NULL) || (ns1->nodeNr <= 0))
5853 return(0);
5854 if ((ns2 == NULL) || (ns2->nodeNr <= 0))
5855 return(0);
5856
5857 /*
5858 * for equal, check if there is a node pertaining to both sets
5859 */
5860 if (neq == 0)
5861 for (i = 0;i < ns1->nodeNr;i++)
5862 for (j = 0;j < ns2->nodeNr;j++)
5863 if (ns1->nodeTab[i] == ns2->nodeTab[j])
5864 return(1);
5865
5866 values1 = (xmlChar **) xmlMalloc(ns1->nodeNr * sizeof(xmlChar *));
5867 if (values1 == NULL) {
5868 xmlXPathPErrMemory(ctxt);
5869 return(0);
5870 }
5871 hashs1 = (unsigned int *) xmlMalloc(ns1->nodeNr * sizeof(unsigned int));
5872 if (hashs1 == NULL) {
5873 xmlXPathPErrMemory(ctxt);
5874 xmlFree(values1);
5875 return(0);
5876 }
5877 memset(values1, 0, ns1->nodeNr * sizeof(xmlChar *));
5878 values2 = (xmlChar **) xmlMalloc(ns2->nodeNr * sizeof(xmlChar *));
5879 if (values2 == NULL) {
5880 xmlXPathPErrMemory(ctxt);
5881 xmlFree(hashs1);
5882 xmlFree(values1);
5883 return(0);
5884 }
5885 hashs2 = (unsigned int *) xmlMalloc(ns2->nodeNr * sizeof(unsigned int));
5886 if (hashs2 == NULL) {
5887 xmlXPathPErrMemory(ctxt);

Callers 2

xmlXPathEqualValuesFunction · 0.85
xmlXPathNotEqualValuesFunction · 0.85

Calls 4

xmlXPathPErrMemoryFunction · 0.85
xmlXPathNodeValHashFunction · 0.85
xmlNodeGetContentFunction · 0.85
xmlStrEqualFunction · 0.85

Tested by

no test coverage detected