Closed RachidAbouSalman closed 7 years ago
Hi,
thx for this library, I was using it and I saw a memory leak while using it. I had a quick look at it, please test the fix below (lines with "//RNR")
hope it helps, it corrected my issue :-)
NSDictionary DictionaryForNode(xmlNodePtr currentNode, NSMutableDictionary parentResult,BOOL parentContent) { NSMutableDictionary resultForNode = [NSMutableDictionary dictionary]; if (currentNode->name) { NSString currentNodeContent = [NSString stringWithCString:(const char *)currentNode->name encoding:NSUTF8StringEncoding]; resultForNode[@"nodeName"] = currentNodeContent; }
xmlChar *nodeContent = xmlNodeGetContent(currentNode); if (nodeContent != NULL) { NSString *currentNodeContent = [NSString stringWithCString:(const char *)nodeContent encoding:NSUTF8StringEncoding]; if ([resultForNode[@"nodeName"] isEqual:@"text"] && parentResult) { if (parentContent) { NSCharacterSet *charactersToTrim = [NSCharacterSet whitespaceAndNewlineCharacterSet]; parentResult[@"nodeContent"] = [currentNodeContent stringByTrimmingCharactersInSet:charactersToTrim]; xmlFree(nodeContent); //RNR return nil; } if (currentNodeContent != nil) { resultForNode[@"nodeContent"] = currentNodeContent; } xmlFree(nodeContent); //RNR return resultForNode; } else { resultForNode[@"nodeContent"] = currentNodeContent; } xmlFree(nodeContent); }
Rachid
Thank you!!!!!!!!!!!!!!!!! This problem has been bothering me for a long time, thank you very much for your
This has been fixed in pull request #80
Hi,
thx for this library, I was using it and I saw a memory leak while using it. I had a quick look at it, please test the fix below (lines with "//RNR")
hope it helps, it corrected my issue :-)
NSDictionary DictionaryForNode(xmlNodePtr currentNode, NSMutableDictionary parentResult,BOOL parentContent) { NSMutableDictionary resultForNode = [NSMutableDictionary dictionary]; if (currentNode->name) { NSString currentNodeContent = [NSString stringWithCString:(const char *)currentNode->name encoding:NSUTF8StringEncoding]; resultForNode[@"nodeName"] = currentNodeContent; }
Rachid