Rev | Line | |
---|
[9] | 1 | /*
|
---|
| 2 | inet/mq.c
|
---|
| 3 |
|
---|
| 4 | Created: Jan 3, 1992 by Philip Homburg
|
---|
| 5 |
|
---|
| 6 | Copyright 1995 Philip Homburg
|
---|
| 7 | */
|
---|
| 8 |
|
---|
| 9 | #include "inet.h"
|
---|
| 10 | #include "mq.h"
|
---|
| 11 | #include "generic/assert.h"
|
---|
| 12 |
|
---|
| 13 | THIS_FILE
|
---|
| 14 |
|
---|
| 15 | #define MQ_SIZE 128
|
---|
| 16 |
|
---|
| 17 | PRIVATE mq_t mq_list[MQ_SIZE];
|
---|
| 18 | PRIVATE mq_t *mq_freelist;
|
---|
| 19 |
|
---|
| 20 | void 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 |
|
---|
| 33 | mq_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 |
|
---|
| 47 | void mq_free(mq)
|
---|
| 48 | mq_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.