]>
Commit | Line | Data |
---|---|---|
1 | /* channelalloc.c */ | |
2 | ||
3 | #include "channel.h" | |
4 | #include "../core/nsmalloc.h" | |
5 | ||
6 | channel *newchan() { | |
7 | return nsmalloc(POOL_CHANNEL, sizeof(channel)); | |
8 | } | |
9 | ||
10 | void freechan(channel *cp) { | |
11 | nsfree(POOL_CHANNEL, cp); | |
12 | } | |
13 | ||
14 | chanuserhash *newchanuserhash(int hashsize) { | |
15 | int i; | |
16 | chanuserhash *cuhp = nsmalloc(POOL_CHANNEL, sizeof(chanuserhash)); | |
17 | ||
18 | if (!cuhp) | |
19 | return NULL; | |
20 | ||
21 | /* Don't use nsmalloc() here since we will free this in freechanuserhash() */ | |
22 | cuhp->content=(unsigned long *)malloc(hashsize*sizeof(unsigned long)); | |
23 | for (i=0;i<hashsize;i++) { | |
24 | cuhp->content[i]=nouser; | |
25 | } | |
26 | ||
27 | cuhp->hashsize=hashsize; | |
28 | cuhp->totalusers=0; | |
29 | ||
30 | return cuhp; | |
31 | } | |
32 | ||
33 | void freechanuserhash(chanuserhash *cuhp) { | |
34 | free(cuhp->content); | |
35 | nsfree(POOL_CHANNEL, cuhp); | |
36 | } |