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