From 26b39f1eae1f576669cbf49c6db94ef4ed8624df Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 24 Sep 2019 19:05:28 +0200 Subject: Fix some reference counters (memleak) (#8981) Fix some reference counters (memleak) Map::dispatchEvent: Allocation safety using references --- src/map.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 67e00c6f4..392ec3f25 100644 --- a/src/map.h +++ b/src/map.h @@ -79,18 +79,7 @@ struct MapEditEvent MapEditEvent() = default; - MapEditEvent * clone() - { - MapEditEvent *event = new MapEditEvent(); - event->type = type; - event->p = p; - event->n = n; - event->modified_blocks = modified_blocks; - event->is_private_change = is_private_change; - return event; - } - - VoxelArea getArea() + VoxelArea getArea() const { switch(type){ case MEET_ADDNODE: @@ -125,7 +114,7 @@ class MapEventReceiver { public: // event shall be deleted by caller after the call. - virtual void onMapEditEvent(MapEditEvent *event) = 0; + virtual void onMapEditEvent(const MapEditEvent &event) = 0; }; class Map /*: public NodeContainer*/ @@ -152,7 +141,7 @@ public: void addEventReceiver(MapEventReceiver *event_receiver); void removeEventReceiver(MapEventReceiver *event_receiver); // event shall be deleted by caller after the call. - void dispatchEvent(MapEditEvent *event); + void dispatchEvent(const MapEditEvent &event); // On failure returns NULL MapSector * getSectorNoGenerateNoLock(v2s16 p2d); -- cgit v1.2.3