Code:
#include "Particles.h"

Particles::Particles(void)
{
}

Particles::~Particles(void)
{

}

void Particles::init(Vector v, int rate, int decay)
{
	pos = v;

	p = new Particle();

	spawnRate = rate;

	halfLife = decay;

	spawnTime = clock() + (spawnRate * CLOCKS_PER_SEC);
}

void Particles::update()
{
	if(clock() >= spawnTime)
	{
		spawn();

		spawnTime = clock() + (spawnRate* CLOCKS_PER_SEC);
	}

	Particle* current;

	current = p;

	if(current->getNext() != NULL)
	{
		current = current->getNext();

		while(current->getNext() != NULL)
		{

			while(current->update() == 0)
			{
				//Particle* d;
				
				//d = current;

				//cout << "Current is: " << current << endl;

				//cout << "D is: " << d << endl;

				//current = current->getNext();

				//cout << "Current is: " << current << endl;

				//cout << "D is: " << d << endl;

				current = deSpawn(current);
			}
			//else
			//{
				current->draw();
			//}

			//cout << "The current nodes new next address is: " << current->getNext() << endl;
			current = current->getNext();
		}
	}
}

void Particles::spawn()
{
	Particle* n = new Particle();

	Colour c;

	c.r = 100;
	c.g = 100;
	c.b = 100;

	n->init(pos, halfLife, c);

	n->setNext(p->getNext());

	p->setNext(n);
}

Particle* Particles::deSpawn(Particle* d)
{
	Particle* current;
	current = p;

	while(current->getNext() != d)
	{
		current = current->getNext();
	}

	current->setNext(d->getNext());
	//cout << "The current nodes new next address is: " << current->getNext() << endl;
	//cout << "The de-spawned Nodes next address is: " << d->getNext() << endl;

	delete d;

	return current->getNext();
}
Hi,

I was trying to create a quick little particle effects system that I was going to build up slowly over time. I ran into a snag with my linked list when the particles life ends. I'll explain basically what's happening, every update a clock is checked to see if it is time to spawn a new particle, these particles are given a life which is also timed against the clock. When the individual particle has reached the end of it's life it returns a 0 which indicates to the particle system it is ready to be removed from the list. It is upon removing the particle from the list and the current position in the linked list moving on to the next position that the program crashes. I've not worked with linked lists for a good couple of months so I'm not sure how to tackle the problem. I assumed that it was because I wasn't moving onto the next position in the list before trying to remove the particle from the list but I've tried nearly every way around this and no luck.

Any help would be much appreciated, thanks in advance.

Hitiro