Firstly, thanks everyone for your replies.
Quote:
Originally Posted by xhi
this is truly the correct way to do this type of thing.. way more efficient.. regardless of why the way you were doing it wont work.
|
While I may well change additem() to take a pointer, the vectors have to store the actual value because the copy outside of the list is overwritten shortly after the call to additem()
(although that probably could be changed)
Quote:
Originally Posted by xhi
i would consider compiling it if you wanted to upload the code..
|
I have uploaded it now, you can find it at
It's got all the source files as well as my Makefile (which doesn't work that well, but that's another story)
http://urzumph.homelinux.org/CalanderThingy.zip
Now, on to the interesting bit.
I noticed when apt-get updateing that there were new versions of some of the things I was using - gcc, glibc, libstdc++ etc, so I updated and tried again. Now, I am getting the same error (except different number), but in a different place. The error seemed to be coming from the resize function...
Code:
Checking to see if calander toadd is the same calander 0
Checking to see if calander toadd is the same calander 1
toadd passed required checks. adding Calander...
pushed back score
pushed back calander
Reordering BestOfList...
Resizing BestOfList...
*** glibc detected *** double free or corruption (!prev): 0x08054558 ***
Added Item to new listmake: *** [test] Aborted
(plese note that in the old logs, they were Reordering calander and resizing calander, I realised these were misleading and fixed them)
Now, I had some vector.erase() calls in resize, and I'm not sure I got them right, so for the meantime, I simply commented them out, leaving this function :
Code:
void BestOfList::resize() {
int lastscore = Scores[Scores.size()-1];
printf("Resizing BestOfList...\n");
if(Scores.size() < minsize) {return;}
for(size_t i = Scores.size()-1;i>=minsize;i--) {
if(Scores.size() < maxsize) {return;}
if(lastscore < Scores[i]) {
//Scores.erase(Scores.begin()+i+1,Scores.end());
//Calanders.erase(Calanders.begin()+i+1,Calanders.end());
}
}
}
(In theory, I needn't have commented them out because Scores.size() should always be less than minsize with this data)
Apparently, this did not stop the problem however.
I am begining to wonder if perhaps stdout needs to be fflush()'d
and lo and behold :
Code:
Adding to list will continue - score >= 0
Checking to see if calander toadd is the same calander 0
Checking to see if calander toadd is the same calander 1
toadd passed required checks. adding Calander...
pushed back score
pushed back calander
Reordering BestOfList...
Resizing BestOfList...
Added Item to new list
*** glibc detected *** double free or corruption (!prev): 0x08054558 ***
So I'll go and add fflush() calls all over the place and try and track down where this error is
(Sorry if this post seems to ramble a bit, I descovered some of the stuff while writing it)
Edit - Tried to fix indentation of code