#include <stdlib.h>



#define total 10
#define colon 201
#define ligne 301

struct ghost {
	int une;
	int col;
	int row;
	struct ghost * back;
	struct ghost * next;
} ;

struct ghost * head = NULL;
struct ghost * tail = NULL;
struct ghost * ici = NULL;

struct ghost * array[total] = { NULL };
struct ghost * matrix[colon][ligne] = { NULL };

/*
void loop(void)
{
			ici = head;
			while (ici->next != NULL)
			{
				...

				ici = ici->next;
			}
}
*/


void creer (void)
{
	if (tail == NULL)
	{
		head = (struct ghost *) malloc(sizeof(struct ghost));
		head->back = NULL;
		head->next = NULL;
		tail = head;
	}
	tail->next = (struct ghost *) malloc(sizeof(struct ghost));
	tail->next->back = tail;
	tail->next->next = NULL;
	tail = tail->next;
	return;
}

void detruire (struct ghost * mort)
{
	if ((mort->back == head)||(mort->next == head))
	{
		return;
	}
	if ((mort == tail)||(mort == head))
	{
		if (mort == tail)
		{
			tail = mort->back;
			mort->back->next = NULL;
			free(mort);
		}
		if (mort == head)
		{
			head = mort->next;
			mort->next->back = NULL;
			free(mort);
		}
	} else {
		mort->back->next = mort->next;
		mort->next->back = mort->back;
		free(mort);
	}
}
