]> git.pond.sub.org Git - empserver/blob - src/client/queue.c
Import of Empire 4.2.12
[empserver] / src / client / queue.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  queue.c: implementation of various queuing routines
29  * 
30  *  Known contributors to this file:
31  *     Steve McClure, 1998
32  */
33
34 #if !defined(_WIN32)
35 #include <unistd.h>
36 #endif
37 #include "misc.h"
38 #include "queue.h"
39
40 void
41 insque(p, q)
42         struct  qelem *p;
43         struct  qelem *q;
44 {
45         p->q_forw = q->q_forw;
46         p->q_back = q;
47         q->q_forw->q_back = p;
48         q->q_forw = p;
49 }
50
51 void
52 remque(p)
53         struct  qelem *p;
54 {
55         p->q_back->q_forw = p->q_forw;
56         p->q_forw->q_back = p->q_back;
57 }
58
59 void
60 initque(p)
61         struct  qelem *p;
62 {
63         p->q_forw = p;
64         p->q_back = p;
65 }
66
67 struct qelem *
68 makeqt(nelem)
69         int     nelem;
70 {
71         extern  s_char *malloc();
72         struct  qelem *table;
73         struct  qelem *qp;
74         int     i;
75
76         table = (struct qelem *) malloc(sizeof(*table) * nelem);
77         for (i=0,qp=table; i<nelem; i++,qp++)
78                 initque(qp);
79         return table;
80 }