From 12ec2bc108e0f0219792cbbe78a6ce7d86818fe3 Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 17 Nov 2007 23:59:39 +0000 Subject: It compiles; ship it. (add some sort of working skeleton for BanCacheManager::RemoveEntries().) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8600 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/bancache.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/bancache.cpp b/src/bancache.cpp index b4fccbbf8..05c014de3 100644 --- a/src/bancache.cpp +++ b/src/bancache.cpp @@ -65,7 +65,36 @@ bool BanCacheManager::RemoveHit(BanCacheHit *b) int BanCacheManager::RemoveEntries(const std::string &type, bool positive) { - return 0; + int removed = 0; + + BanCacheHash::iterator safei; + + for (BanCacheHash::iterator n = BanHash->begin(); n != BanHash->end(); ) + { + safei = n; + safei++; + + BanCacheHit *b = n->second; + + /* Safe to delete items here through iterator 'n' */ + if (b->Type == type) + { + if ((positive && !b->Reason.empty()) || b->Reason.empty()) + { + /* we need to remove this one. */ + delete b; + b = NULL; + BanHash->erase(n); + removed++; + } + } + + /* End of safe section */ + n = safei; + } + + + return removed; } void BanCacheManager::RehashCache() -- cgit v1.2.3