mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Fixed minimap memory leak
This commit is contained in:
parent
9bc0241e44
commit
88a6b9f52d
4 changed files with 16 additions and 8 deletions
|
@ -102,7 +102,13 @@ void MinimapUpdateThread::doUpdate()
|
|||
|
||||
while (popBlockUpdate(&update)) {
|
||||
if (update.data) {
|
||||
m_blocks_cache[update.pos] = update.data;
|
||||
// Swap two values in the map using single lookup
|
||||
std::pair<std::map<v3s16, MinimapMapblock*>::iterator, bool>
|
||||
result = m_blocks_cache.insert(std::make_pair(update.pos, update.data));
|
||||
if (result.second == false) {
|
||||
delete result.first->second;
|
||||
result.first->second = update.data;
|
||||
}
|
||||
} else {
|
||||
std::map<v3s16, MinimapMapblock *>::iterator it;
|
||||
it = m_blocks_cache.find(update.pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue