This is driving me nuts, so I came here.
This is called every frame.
class CTestTask : public ITask
std::list < particle * > particles;
if (*part)->TestParticle() returns false, it should delete the memory for the particle and then delete the pointer from the linked list.
for( int i = 0; i < (PARTICLES_ADDED_PER_SECOND+1; i++ )
particles.push_back( new SnowParticle );
for (std::list<particle*>::iterator part=particles.begin(); part != particles.end(); part++)
// We first test the particle to see if it should remain alive
//(*part) = new SnowParticle;
if( (*part)->TestParticle() )
// If it should, we update and draw the particle
// And then move onto the next particle
// If we end it here, then it continues until the point that it would have crashed, and stops making particles???
// Otherwise we cut the particle out of the list, and trash it.
//particle * oldparticle = (*part);
particles.erase( part, part );
This causes a crash . If I don't free the memory from the new, then it works, but there's a memory leak...