Hi All
Based on the information below. When I call gradeArticle(myArticle, text) I get an error (free(): invalid pointer). The code works the first time and seems to error when called again. Even with all the code commented out of the gradeArticle method I still get the same error. I suspect its to do with memory being used, but I don't know how to solve the problem.
Many thanks.
I have the following structs
typedef struct{
string tTerm;
int tf;
} XapianWord;
typedef struct{
vector<XapianWord> words;
string text;
double score;
int wc;
int order;
} XapianSentence;
typedef struct{
vector<XapianSentence> lines;
vector<XapianWord> wordStat;
vector<XapianWord> ImpWords;
} XapianArticle;
And the following code
string getSummary(string text, string type, int sentences, int characters, bool highlight){
if(text.size() == 0){return("");}
if(sentences == 0){sentences = 2;}
string returnText = "Problem getting summary";
XapianArticle myArticle;
gradeArticle(myArticle, text); <--- Error occurs here
.....
string gradeArticle(XapianArticle &myArticle, string text){
......
And I get the following error.
free(): invalid pointer: 0xb6bcefb5 ***
0xb7fe5410 in ?? ()
(gdb) up
#1 0xb6bce59c in ?? ()
(gdb) up
#2 0x00000006 in ?? ()
(gdb) up
#3 0x00000503 in ?? ()
(gdb) up
#4 0xb7c11770 in raise () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#5 0xb7c12ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#6 0xb7c46d0b in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#7 0xb7c4e8bd in mallopt () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#8 0xb7c4ea44 in free () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#9 0xb7dfdfc1 in operator delete () from /usr/lib/libstdc++.so.6
(gdb) up
#10 0xb7ddad3d in std::string::_Rep::_M_destroy () from /usr/lib/libstdc++.so.6
(gdb) up
#11 0xb7ddd8c7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string () from /usr/lib/libstdc++.so.6
(gdb) up
#12 0x08061d72 in getSummary ()
(gdb)