diff --git a/src/cache.cpp b/src/cache.cpp index a0004c8..2bf850a 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -213,9 +213,10 @@ void StatCache::Clear() { AutoLock lock(&StatCache::stat_cache_lock); - for(stat_cache_t::iterator iter = stat_cache.begin(); iter != stat_cache.end(); stat_cache.erase(iter++)){ + for(stat_cache_t::iterator iter = stat_cache.begin(); iter != stat_cache.end(); ++iter){ delete (*iter).second; } + stat_cache.clear(); S3FS_MALLOCTRIM(0); } diff --git a/src/curl.cpp b/src/curl.cpp index 5ccc25c..471fb92 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -3974,21 +3974,24 @@ S3fsMultiCurl::~S3fsMultiCurl() bool S3fsMultiCurl::ClearEx(bool is_all) { s3fscurlmap_t::iterator iter; - for(iter = cMap_req.begin(); iter != cMap_req.end(); cMap_req.erase(iter++)){ + for(iter = cMap_req.begin(); iter != cMap_req.end(); ++iter){ S3fsCurl* s3fscurl = (*iter).second; if(s3fscurl){ s3fscurl->DestroyCurlHandle(); delete s3fscurl; // with destroy curl handle. } } + cMap_req.clear(); if(is_all){ - for(iter = cMap_all.begin(); iter != cMap_all.end(); cMap_all.erase(iter++)){ + for(iter = cMap_all.begin(); iter != cMap_all.end(); ++iter){ S3fsCurl* s3fscurl = (*iter).second; s3fscurl->DestroyCurlHandle(); delete s3fscurl; } + cMap_all.clear(); } + S3FS_MALLOCTRIM(0); return true; @@ -4094,7 +4097,7 @@ int S3fsMultiCurl::MultiPerform() int S3fsMultiCurl::MultiRead() { - for(s3fscurlmap_t::iterator iter = cMap_req.begin(); iter != cMap_req.end(); cMap_req.erase(iter++)) { + for(s3fscurlmap_t::iterator iter = cMap_req.begin(); iter != cMap_req.end(); ++iter) { S3fsCurl* s3fscurl = (*iter).second; bool isRetry = false; @@ -4155,6 +4158,8 @@ int S3fsMultiCurl::MultiRead() } } } + cMap_req.clear(); + return 0; } @@ -4171,12 +4176,13 @@ int S3fsMultiCurl::Request() // set curl handle to multi handle int result; s3fscurlmap_t::iterator iter; - for(iter = cMap_all.begin(); iter != cMap_all.end(); cMap_all.erase(iter++)){ + for(iter = cMap_all.begin(); iter != cMap_all.end(); ++iter){ CURL* hCurl = (*iter).first; S3fsCurl* s3fscurl = (*iter).second; cMap_req[hCurl] = s3fscurl; } + cMap_all.clear(); // Send multi request. if(0 != (result = MultiPerform())){ diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 197781d..9771fe1 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -2884,9 +2884,10 @@ static int remote_mountpath_exists(const char* path) static void free_xattrs(xattrs_t& xattrs) { - for(xattrs_t::iterator iter = xattrs.begin(); iter != xattrs.end(); xattrs.erase(iter++)){ + for(xattrs_t::iterator iter = xattrs.begin(); iter != xattrs.end(); ++iter){ delete iter->second; } + xattrs.clear(); } static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTRVAL& pval)