tpctt / tfhpple Goto Github PK
View Code? Open in Web Editor NEWpod 'TFHpple' 将 html 解析改成了 pod 管理, 有问题请 issue
License: MIT License
pod 'TFHpple' 将 html 解析改成了 pod 管理, 有问题请 issue
License: MIT License
Hi,
We have code which does parsing of SOAP xml, and we use xmlNodeGetContent api. In valgrind it shows that it leaking memory. What i found in some posts that we need to explicitly free the memory returned by xmlNodeGetContent. Can someone help me on how to do this for below recursive calls?
void getSoapMsgDetails(xmlNode* node)
{
while(node)
{
if(XML_ELEMENT_NODE == node->type)
{
if(0 == strcmp( soapMsgHeader.c_str() ,(const char*)node->name ) )
{
xmlNode childNode=node->children;
while(childNode)
{
if( (XML_ELEMENT_NODE == childNode->type) && ( 0 == ( xmlChildElementCount(childNode) ) ) )
{
std::string name= (const char)childNode->name;
std::string value = (const char*)xmlNodeGetContent(childNode);
soapHeaderAttributes.insert(std::pair< std::string, std::string> (name,value) );
}
childNode=childNode->next;
}
}
if(0 == strcmp(soapMsgMo.c_str(), (const char*)node->name))
{
getSoapMsgMoList(node);
}
if(0 == strcmp(soapMsgBody.c_str(), (const char*)node->name))
{
node = node->children;
while(XML_ELEMENT_NODE != node->type)
{
node = node->next;
}
msgTypeVal = (char*)node->name;
node = node->parent;
}
}
getSoapMsgDetails(node->children);
node = node->next;
}
}
in XPathQuery.m line29
xmlChar *nodeContent = xmlNodeGetContent(currentNode);
this nodeContent seems to be leak in next code
if ([resultForNode[@"nodeName"] isEqual:@"text"] && parentResult) {
if this code is excuted the nodeContent is not free
First of all, I really like this library, you doing a great job thank you for maintaining it.
I have a serious problem, and its already one week i'm not able to solve it.
I'm calling on a method which does the following
private class func getVideoAttribute(forKey key: String, source: String) -> Any? {
let parser = TFHpple(htmlData: source.data(using: .utf8, allowLossyConversion: false))!
**if let videos = parser.search(withXPathQuery: "//video")** // Crash happens here.
actually when going inside the error i can see it's crash on this line...
NSArray *PerformHTMLXPathQueryWithEncoding(NSData *document, NSString *query,NSString *encoding)
{
xmlDocPtr doc;
/* Load XML document */
const char *encoded = encoding ? [encoding cStringUsingEncoding:NSUTF8StringEncoding] : NULL;
// Error happens herein the next line
**doc = htmlReadMemory([document bytes], (int)[document length], "", encoded, HTML_PARSE_NOWARNING |
HTML_PARSE_NOERROR);**
if (doc == NULL) {
NSLog(@"Unable to parse.");
return nil;
}
NSArray *result = PerformXPathQuery(doc, query);
xmlFreeDoc(doc);
return result;
}
any idea way it's happening only on real device ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.