#ifndef lint
static char *RCSid = "$Header: queue.c 1.3 89/06/09 $";
#endif /* not lint */

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

#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	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;
}
