diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-05 19:52:16 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-05 19:52:16 +0000 |
commit | 91a3d1324b70945b52acb607470336c562280ff4 (patch) | |
tree | c5aeb8b6011c9477e88fe0a8b1158437993f3c45 /src/bancache.cpp | |
parent | 477681996b164c8dacc930c3df378129a3bf929d (diff) |
Rehash method added which frees unused memory from the hash_map. Has a delete-safe iterator. see comments.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8542 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/bancache.cpp')
-rw-r--r-- | src/bancache.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bancache.cpp b/src/bancache.cpp index a831b1219..bfa1bde11 100644 --- a/src/bancache.cpp +++ b/src/bancache.cpp @@ -63,4 +63,26 @@ bool BanCacheManager::RemoveHit(BanCacheHit *b) return true; } +void BanCacheManager::RehashCache() +{ + BanCacheHash* NewHash = new BanCacheHash(); + + BanCacheHash::iterator safei; + for (BanCacheHash::iterator n = BanHash->begin(); n != BanHash->end(); ) + { + safei = n; + safei++; + + /* Safe to delete items here through iterator 'n' */ + + /* Actually inserts a std::pair */ + NewHash->insert(*n); + /* End of safe section */ + + n = safei; + } + + delete BanHash; + BanHash = NewHash; +} |