source: trunk/minix/servers/inet/mq.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 797 bytes
Line 
1/*
2inet/mq.c
3
4Created: Jan 3, 1992 by Philip Homburg
5
6Copyright 1995 Philip Homburg
7*/
8
9#include "inet.h"
10#include "mq.h"
11#include "generic/assert.h"
12
13THIS_FILE
14
15#define MQ_SIZE 128
16
17PRIVATE mq_t mq_list[MQ_SIZE];
18PRIVATE mq_t *mq_freelist;
19
20void mq_init()
21{
22 int i;
23
24 mq_freelist= NULL;
25 for (i= 0; i<MQ_SIZE; i++)
26 {
27 mq_list[i].mq_next= mq_freelist;
28 mq_freelist= &mq_list[i];
29 mq_list[i].mq_allocated= 0;
30 }
31}
32
33mq_t *mq_get()
34{
35 mq_t *mq;
36
37 mq= mq_freelist;
38 assert(mq != NULL);
39
40 mq_freelist= mq->mq_next;
41 mq->mq_next= NULL;
42 assert(mq->mq_allocated == 0);
43 mq->mq_allocated= 1;
44 return mq;
45}
46
47void mq_free(mq)
48mq_t *mq;
49{
50 mq->mq_next= mq_freelist;
51 mq_freelist= mq;
52 assert(mq->mq_allocated == 1);
53 mq->mq_allocated= 0;
54}
55
56/*
57 * $PchId: mq.c,v 1.7 1998/10/23 20:10:47 philip Exp $
58 */
Note: See TracBrowser for help on using the repository browser.