> First hand Info:
> Xerces-c++ 1.6 on Solaris 5.7
> 
> Sorry for the long  email..
> 
> 
> I have written a tuxedo server, which will create DOM parser globally and
> keep it in memory during startup.
> 
> Now, when request start coming in for this server, in the form of xml
> strings, It will parse using 'MemBufInputSource-technique' and traverse
> the entire tree, looking for certain elements and pass those elements'
> values back in a C structure.
> 
> Now i run this test 100 times, with just the parsing stuff, (using purify
> to detect memory violations) and tree manipukation being commented out,
> and it goes just fine with no leak.
> 
> Then i run the complete code, including the parsing and tree manipulation,
> In about 5 runs, the purify shows leaks in the parsing statement and not
> in the tree manipulation code
> 
> (ie at: Parser->parse(*memBufIs))
> 
> As far as tree manipulation is concerned, i pass the root node to a
> function and in a recursive loop, check each node's value to look for my
> desired search criteria..
> 
> My doubt is that the DOM gets confused on how to cleanup the root node,
> because i keep changing it in the recursive function.
> 
> 
> 
> Let me attch the function below:
> 
> 
> 
> void
> __populate_resultDOM(DOM_Node root1, lookupDom_t *lookup, resultDom_t
> *result)
> { 
> int ii=0, hasChildren = 0, nulNode = 0;
> static int break_el_ctr = 0, break_attr_ctr;
> char *name = NULL, *value = NULL, *out = NULL, *value_flg = SA_NO_VALUE;
> 
> if(root1.isNull())
> nulNode = 1;
> 
> if(!nulNode)
> hasChildren = root1.hasChildNodes();
> 
> if(!nulNode && (root1.getNodeType() == DOM_Node::ELEMENT_NODE))
> {
> name = root1.getNodeName().transcode();
> if(hasChildren) 
>               value= root1.getFirstChild().getNodeValue().transcode();
>       for(ii=0; ii<(lookup->element_count); ii++)
>       { 
>               if(strcasecmp((const char *)(lookup->element_name+ii), name)
> == 0)
>               { 
>                       //(result->element+ii)->el_node =
> root1.cloneNode(true);
>                       (result->element+ii)->el_node = root1;
>                       if(value)
>                       {
> (result->element+ii)->element_value = (char
> *)realloc((result->element+ii)->element_value, sizeof(char) *
> (strlen(value) +
> 1)); 
>                       strcpy((result->element+ii)->element_value, value);
>                       }
>                       ++result->element_count;
>                       break;
>       }
>       }
>       for(ii=0; ii<(lookup->attr_count); ii++)
>       { 
>               if(strcasecmp((const char
> *)(lookup->el_attr_name+ii)->at_element_name,name) == 0)
>               
>               {
>               strcpy((result->attribute+ii)->el_attr.at_element_name,
> name);
>               //(result->attribute+ii)->el_attr_node =
> root1.cloneNode(true);
>               (result->attribute+ii)->el_attr_node = root1;
>                       DOM_NamedNodeMap attributes = root1.getAttributes();
>                       int attrCount = attributes.getLength();
>                       char *attr_value = NULL, *attr_name = NULL;
>                       
>                       for (int i = 0; i < attrCount; i++)
>                       {
>                       DOM_Node attribute = attributes.item(i);
>                       //attr_name = attribute.getNodeName().transcode();
>       
> if(attribute.getNodeName().equals((lookup->el_attr_name+ii)->attr_name))
>                       { 
>                       attr_value = attribute.getNodeValue().transcode();
>                       if(attr_value)
>                       {
> (result->attribute+ii)->attr_value = (char
> *)realloc((result->attribute+ii)->attr_value, sizeof(char) *
> (strlen(attr_v
> alue) + 1)); 
>                       strcpy((result->attribute+ii)->attr_value,
> attr_value);
>                       delete[] attr_value;
>                       attr_value = 0;
>                       }
>                       ++result->attr_count;
>                       break;
>                       }
>                       }
>       }
>       }
>       delete[] name;
>       name = 0;
>       delete[] value;
>       value = 0;
> }
> 
> if(hasChildren && ((result->attr_count + result->element_count) !=
> (lookup->attr_count+lookup->element_count)))
> {
> if(nulNode)
> return;
> DOM_NodeList children = root1.getChildNodes();
> for(int jj = 0; jj<children.getLength(); jj++)
> { 
>               __populate_resultDOM((children.item(jj)), lookup, result);
>               if((result->attr_count + result->element_count)==
> (lookup->attr_count+lookup->element_count))
>       return;
>       }
>       }
>       return;
> }
> 
> Please help me resolving this issue.
> 
> Thanks a ton! 
> 
> 
> Arun Ramadoss
> Professional
> Software Engineer II
> E*TRADE Financial
> w 650-331-6307
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to