#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emp2/client/queue.c,v 1.1 1994/11/30 22:51:52 empire Exp $";
#endif /* not lint */

/*
 * queue.c
 *
 * implementation of insque and remque,
 * among other things.
 *
 */

#include "misc.h"
#include "queue.h"

insque(p, q)
	struct	qelem *p;
	struct	qelem *q;
{
	p->q_forw = q->q_forw;
	p->q_back = q;
	q->q_forw->q_back = p;
	q->q_forw = p;
}

remque(p)
	struct	qelem *p;
{
	p->q_back->q_forw = p->q_forw;
	p->q_forw->q_back = p->q_back;
}

initque(p)
	struct	qelem *p;
{
	p->q_forw = p;
	p->q_back = p;
}

struct qelem *
makeqt(nelem)
	int	nelem;
{
	extern	s_char *malloc();
	struct	qelem *table;
	struct	qelem *qp;
	int	i;

	table = (struct qelem *) malloc(sizeof(*table) * nelem);
	for (i=0,qp=table; i<nelem; i++,qp++)
		initque(qp);
	return table;
}
