Hi!! After some times lurking this is my first question...
I'm working on a function that should remove any tag from an HTML page and split all the remaining text into an array.
Here is the code:
It compiles and work for a little, then after some pages I get this error:Code:char **html::getPageKeywords() { Pattern * p = Pattern::compile("<body[^>]*?>(.+?)</body[^>]*?>"); Matcher * m = p->createMatcher(getPage()); char * c = getPage();//&v[0]; std::string temp; temp=p->replace("<script[^>]*?>(.+?)</script[^>]*?>",c,""); temp=p->replace("<[^>]*?>",temp,""); temp=p->replace("</[^>]*?>",temp,""); temp=p->replace("<[^>]*?/>",temp,""); std::vector<char> z(temp.length() + 1); std::strcpy(&z[0], temp.c_str()); c = &z[0]; char *out = new char[(signed)strlen(c)+1]; UnToken(c,tokens,out); // removes characters like @ # $ % ^ & * ; : ' . and so on... char *no2spaces = new char[(signed)strlen(out)+1]; no2spaces=out; OnlyOneSpace(no2spaces); // removes doubled spaces char *pch = new char[(signed)strlen(out)]; pch=strtok(no2spaces," "); char **keywords=new char*[(signed)strlen(out)]; int x=0; while (pch!=NULL) { char * chiave=new char[strlen(pch)+1]; chiave=pch; if (chiave[0] != ' ' && strlen(chiave) != 0) keywords[x]=chiave; pch=strtok(NULL, " "); x++; } return keywords; }
Where 0x08b9b160 alwys change.Code:*** glibc detected *** corrupted double-linked list: 0x08b9b160 ***
I can't figure out why...any idea?
Thank you in advance!



LinkBack URL
About LinkBacks


