1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Fix some reference counters (memleak) (#8981)

Fix some reference counters (memleak)
Map::dispatchEvent: Allocation safety using references
This commit is contained in:
SmallJoker 2019-09-24 19:05:28 +02:00 committed by GitHub
parent d77ea76476
commit 26b39f1eae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 30 additions and 37 deletions

View file

@ -306,6 +306,11 @@ Server::~Server()
for (auto &detached_inventory : m_detached_inventories) {
delete detached_inventory.second;
}
while (!m_unsent_map_edit_queue.empty()) {
delete m_unsent_map_edit_queue.front();
m_unsent_map_edit_queue.pop();
}
}
void Server::init()
@ -1090,12 +1095,12 @@ void Server::setTimeOfDay(u32 time)
m_time_of_day_send_timer = 0;
}
void Server::onMapEditEvent(MapEditEvent *event)
void Server::onMapEditEvent(const MapEditEvent &event)
{
if (m_ignore_map_edit_events_area.contains(event->getArea()))
if (m_ignore_map_edit_events_area.contains(event.getArea()))
return;
MapEditEvent *e = event->clone();
m_unsent_map_edit_queue.push(e);
m_unsent_map_edit_queue.push(new MapEditEvent(event));
}
Inventory* Server::getInventory(const InventoryLocation &loc)
@ -1160,7 +1165,7 @@ void Server::setInventoryModified(const InventoryLocation &loc)
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
event.p = loc.p;
m_env->getMap().dispatchEvent(&event);
m_env->getMap().dispatchEvent(event);
}
break;
case InventoryLocation::DETACHED: