Module: ngircd.git Branch: master Commit: 40a0e9abbe8cfd959dd920f2af32976f1eda1a6a URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=40a0e...
Author: Florian Westphal fw@strlen.de Date: Sun Jan 4 22:50:49 2009 +0100
Add Channel_Free().
Central function to free a channel structure and all its resources (invite/ban lists, topic, ...).
---
src/ngircd/channel.c | 36 +++++++++++++++++++++--------------- 1 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index b93f223..ba5e725 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -57,7 +57,8 @@ static CL2CHAN *Add_Client PARAMS(( CHANNEL *Chan, CLIENT *Client )); static bool Remove_Client PARAMS(( int Type, CHANNEL *Chan, CLIENT *Client, CLIENT *Origin, const char *Reason, bool InformServer )); static CL2CHAN *Get_First_Cl2Chan PARAMS(( CLIENT *Client, CHANNEL *Chan )); static CL2CHAN *Get_Next_Cl2Chan PARAMS(( CL2CHAN *Start, CLIENT *Client, CHANNEL *Chan )); -static bool Delete_Channel PARAMS(( CHANNEL *Chan )); +static void Delete_Channel PARAMS(( CHANNEL *Chan )); +static void Channel_Free PARAMS(( CHANNEL *Chan ));
GLOBAL void @@ -146,6 +147,17 @@ Channel_InitPredefined( void ) } /* Channel_InitPredefined */
+static void +Channel_Free(CHANNEL *chan) +{ + array_free(&chan->topic); + Lists_Free(&chan->list_bans); + Lists_Free(&chan->list_invites); + + free(chan); +} + + GLOBAL void Channel_Exit( void ) { @@ -154,11 +166,9 @@ Channel_Exit( void )
/* free struct Channel */ c = My_Channels; - while( c ) - { + while (c) { c_next = c->next; - array_free(&c->topic); - free( c ); + Channel_Free(c); c = c_next; }
@@ -1070,7 +1080,7 @@ Get_Next_Cl2Chan( CL2CHAN *Start, CLIENT *Client, CHANNEL *Channel ) /** * Remove a channel and free all of its data structures. */ -static bool +static void Delete_Channel(CHANNEL *Chan) { CHANNEL *chan, *last_chan; @@ -1083,23 +1093,19 @@ Delete_Channel(CHANNEL *Chan) last_chan = chan; chan = chan->next; } - if (!chan) - return false;
- Log(LOG_DEBUG, "Freed channel structure for "%s".", Chan->name); - - array_free(&chan->topic); - Lists_Free(&chan->list_bans); - Lists_Free(&chan->list_invites); + assert(chan != NULL); + if (!chan) + return;
/* maintain channel list */ if (last_chan) last_chan->next = chan->next; else My_Channels = chan->next; - free(chan);
- return true; + LogDebug("Freed channel structure for "%s".", Chan->name); + Channel_Free(Chan); } /* Delete_Channel */
ngircd-commits@lists.barton.de