void DeleteClient(struct Luser *user) { struct UserChannel *chnext; #ifdef NICKSERVICES struct NickInfo *nptr, *realptr; #ifdef CHANNELSERVICES struct aChannelPtr *fnext; #endif #endif /* NICKSERVICES */ if (user == NULL) return; SendUmode(OPERUMODE_CAPE, "*** Client exit: %s!%s@%s [%s]", user->nick, user->username, user->hostname, user->server ? user->server->name : "*unknown*"); #ifdef NICKSERVICES realptr = FindNick(user->nick); nptr = GetMaster(realptr); if (nptr && realptr) { if (LastSeenInfo && (realptr->flags & NS_IDENTIFIED)) { /* * Update last seen user@host info */ if (realptr->lastu) MyFree(realptr->lastu); if (realptr->lasth) MyFree(realptr->lasth); realptr->lastu = MyStrdup(user->username); realptr->lasth = MyStrdup(user->hostname); } /* * they're quitting - unmark them as identified */ realptr->flags &= ~NS_IDENTIFIED; } #ifdef CHANNELSERVICES while (user->founder_channels) { fnext = user->founder_channels->next; RemFounder(user, user->founder_channels->cptr); user->founder_channels = fnext; } #endif #endif /* NICKSERVICES */ #ifdef ALLOW_FUCKOVER /* check if user was a target of o_fuckover() */ CheckFuckoverTarget(user, NULL); #endif if (user->server) user->server->numusers--; while (user->firstchan) { chnext = user->firstchan->next; RemoveFromChannel(user->firstchan->chptr, user); user->firstchan = chnext; } HashDelClient(user, 0); /* keep oper count updated */ if (user->umodes & UMODE_O) { Network->TotalOperators--; if (user->server) user->server->numopers--; } #ifndef BLOCK_ALLOCATION MyFree(user->nick); MyFree(user->username); MyFree(user->hostname); MyFree(user->realname); #endif /* BLOCK_ALLOCATION */ if (user->prev) user->prev->next = user->next; else ClientList = user->next; if (user->next) user->next->prev = user->prev; #ifdef BLOCK_ALLOCATION BlockSubFree(ClientHeap, user); #else MyFree(user); #endif /* BLOCK_ALLOCATION */ Network->TotalUsers--; } /* DeleteClient() */
void DeleteChannel(struct Channel *cptr) { struct ChannelUser *cnext; struct ChannelBan *bnext; struct Exception *enext; #ifdef GECOSBANS struct ChannelGecosBan *gnext; #endif /* GECOSBANS */ #ifdef HYBRID7 struct InviteException *inext; #endif /* HYBRID7 */ if (!cptr) return; HashDelChan(cptr); /* * right now, having a loop to free the members of the channel * is unnecessary, because this function is only called either * from RemoveFromChannel(), which already took care of it, * or from ClearChans(), which is called after ClearUsers() - * ClearUsers() would have called RemoveFromChannel() to * clear each user's channel list - thus cptr->firstuser will * ALWAYS be null, however, this could possibly develop into a * memory leak, if DeleteChannel() were ever to be called with * users still in the channel, so this algorithm will take care * of it. */ while (cptr->firstuser) { cnext = cptr->firstuser->next; MyFree(cptr->firstuser); cptr->firstuser = cnext; } /* * clear channel bans */ while (cptr->firstban) { bnext = cptr->firstban->next; if (cptr->firstban->who) MyFree(cptr->firstban->who); MyFree(cptr->firstban->mask); MyFree(cptr->firstban); cptr->firstban = bnext; } #ifdef GECOSBANS /* * clear channel denies */ while (cptr->firstgecosban) { gnext = cptr->firstgecosban->next; if (cptr->firstgecosban->who) MyFree(cptr->firstgecosban->who); MyFree(cptr->firstgecosban->mask); MyFree(cptr->firstgecosban); cptr->firstgecosban = gnext; } #endif /* GECOSBANS */ /* * clear channel exceptions */ while (cptr->exceptlist) { enext = cptr->exceptlist->next; MyFree(cptr->exceptlist->who); MyFree(cptr->exceptlist->mask); MyFree(cptr->exceptlist); cptr->exceptlist = enext; } #ifdef HYBRID7 /* Clear channel invite exceptions -Janos */ while (cptr->inviteexceptlist) { inext = cptr->inviteexceptlist->next; MyFree(cptr->inviteexceptlist->who); MyFree(cptr->inviteexceptlist->mask); MyFree(cptr->inviteexceptlist); cptr->inviteexceptlist = inext; } #endif /* HYBRID7 */ #ifndef BLOCK_ALLOCATION MyFree(cptr->name); if (cptr->key) MyFree(cptr->key); if (cptr->forward) MyFree(cptr->forward); #endif /* BLOCK_ALLOCATION */ if (cptr->prev) cptr->prev->next = cptr->next; else ChannelList = cptr->next; if (cptr->next) cptr->next->prev = cptr->prev; #ifdef BLOCK_ALLOCATION BlockSubFree(ChannelHeap, cptr); #else MyFree(cptr); #endif /* BLOCK_ALLOCATION */ --Network->TotalChannels; } /* DeleteChannel() */