summaryrefslogtreecommitdiff
path: root/lib/backupstore/BackupStoreContext.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-02-10 13:52:11 +0000
committerChris Wilson <chris+github@qwirx.com>2014-02-10 13:52:11 +0000
commit6d4016cc9d7be0bd3c8110382076cae35d9be161 (patch)
treee254d51c00c501ce30079c0f4a5fdddc4d65abce /lib/backupstore/BackupStoreContext.cpp
parent31c7bfed9caa2e245377c458bc1c271eed61c5f4 (diff)
Add a ClearDirectoryCache method to BackupStoreContext.
It's used in several places, and about to be one more.
Diffstat (limited to 'lib/backupstore/BackupStoreContext.cpp')
-rw-r--r--lib/backupstore/BackupStoreContext.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/backupstore/BackupStoreContext.cpp b/lib/backupstore/BackupStoreContext.cpp
index db0b11c8..7548cba6 100644
--- a/lib/backupstore/BackupStoreContext.cpp
+++ b/lib/backupstore/BackupStoreContext.cpp
@@ -79,14 +79,20 @@ BackupStoreContext::BackupStoreContext(int32_t ClientID,
// --------------------------------------------------------------------------
BackupStoreContext::~BackupStoreContext()
{
+ ClearDirectoryCache();
+}
+
+void BackupStoreContext::ClearDirectoryCache()
+{
// Delete the objects in the cache
- for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin()); i != mDirectoryCache.end(); ++i)
+ for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin());
+ i != mDirectoryCache.end(); ++i)
{
delete (i->second);
}
+ mDirectoryCache.clear();
}
-
// --------------------------------------------------------------------------
//
// Function
@@ -321,11 +327,7 @@ BackupStoreDirectory &BackupStoreContext::GetDirectoryInternal(int64_t ObjectID)
if(mDirectoryCache.size() > MAX_CACHE_SIZE)
{
// Very simple. Just delete everything!
- for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin()); i != mDirectoryCache.end(); ++i)
- {
- delete (i->second);
- }
- mDirectoryCache.clear();
+ ClearDirectoryCache();
}
// Get a RaidFileRead to read it