summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bancache.cpp31
1 files changed, 30 insertions, 1 deletions
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()