forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmq.c
More file actions
58 lines (45 loc) · 795 Bytes
/
Copy pathmq.c
File metadata and controls
58 lines (45 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
inet/mq.c
Created: Jan 3, 1992 by Philip Homburg
Copyright 1995 Philip Homburg
*/
#include "inet.h"
#include "mq.h"
#include "generic/assert.h"
THIS_FILE
#define MQ_SIZE 128
static mq_t mq_list[MQ_SIZE];
static mq_t *mq_freelist;
void mq_init()
{
int i;
mq_freelist= NULL;
for (i= 0; i<MQ_SIZE; i++)
{
mq_list[i].mq_next= mq_freelist;
mq_freelist= &mq_list[i];
mq_list[i].mq_allocated= 0;
}
}
mq_t *mq_get()
{
mq_t *mq;
mq= mq_freelist;
assert(mq != NULL);
mq_freelist= mq->mq_next;
mq->mq_next= NULL;
assert(mq->mq_allocated == 0);
mq->mq_allocated= 1;
return mq;
}
void mq_free(mq)
mq_t *mq;
{
mq->mq_next= mq_freelist;
mq_freelist= mq;
assert(mq->mq_allocated == 1);
mq->mq_allocated= 0;
}
/*
* $PchId: mq.c,v 1.7 1998/10/23 20:10:47 philip Exp $
*/