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

Function xmlXPathNodeValHash

ThirdParty/libxml2/vtklibxml2/xpath.c:5307–5409  ·  view source on GitHub ↗

* xmlXPathNodeValHash: * @node: a node pointer * * Function computing the beginning of the string value of the node, * used to speed up comparisons * * Returns an int usable as a hash */

Source from the content-addressed store, hash-verified

5305 * Returns an int usable as a hash
5306 */
5307static unsigned int
5308xmlXPathNodeValHash(xmlNodePtr node) {
5309 int len = 2;
5310 const xmlChar * string = NULL;
5311 xmlNodePtr tmp = NULL;
5312 unsigned int ret = 0;
5313
5314 if (node == NULL)
5315 return(0);
5316
5317 if (node->type == XML_DOCUMENT_NODE) {
5318 tmp = xmlDocGetRootElement((xmlDocPtr) node);
5319 if (tmp == NULL)
5320 node = node->children;
5321 else
5322 node = tmp;
5323
5324 if (node == NULL)
5325 return(0);
5326 }
5327
5328 switch (node->type) {
5329 case XML_COMMENT_NODE:
5330 case XML_PI_NODE:
5331 case XML_CDATA_SECTION_NODE:
5332 case XML_TEXT_NODE:
5333 string = node->content;
5334 if (string == NULL)
5335 return(0);
5336 if (string[0] == 0)
5337 return(0);
5338 return(string[0] + (string[1] << 8));
5339 case XML_NAMESPACE_DECL:
5340 string = ((xmlNsPtr)node)->href;
5341 if (string == NULL)
5342 return(0);
5343 if (string[0] == 0)
5344 return(0);
5345 return(string[0] + (string[1] << 8));
5346 case XML_ATTRIBUTE_NODE:
5347 tmp = ((xmlAttrPtr) node)->children;
5348 break;
5349 case XML_ELEMENT_NODE:
5350 tmp = node->children;
5351 break;
5352 default:
5353 return(0);
5354 }
5355 while (tmp != NULL) {
5356 switch (tmp->type) {
5357 case XML_CDATA_SECTION_NODE:
5358 case XML_TEXT_NODE:
5359 string = tmp->content;
5360 break;
5361 default:
5362 string = NULL;
5363 break;
5364 }

Callers 2

xmlXPathEqualNodeSetsFunction · 0.85

Calls 1

xmlDocGetRootElementFunction · 0.85

Tested by

no test coverage detected