summaryrefslogtreecommitdiff
path: root/src/map.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-09-24 19:05:28 +0200
committerGitHub <noreply@github.com>2019-09-24 19:05:28 +0200
commit26b39f1eae1f576669cbf49c6db94ef4ed8624df (patch)
treedd0a508d4d6987f2c667cbf342955f64ebbd02af /src/map.h
parentd77ea764768f5cde9e8f0781356a67d723aa7609 (diff)
downloadminetest-26b39f1eae1f576669cbf49c6db94ef4ed8624df.tar.gz
minetest-26b39f1eae1f576669cbf49c6db94ef4ed8624df.tar.bz2
minetest-26b39f1eae1f576669cbf49c6db94ef4ed8624df.zip
Fix some reference counters (memleak) (#8981)
Fix some reference counters (memleak) Map::dispatchEvent: Allocation safety using references
Diffstat (limited to 'src/map.h')
-rw-r--r--src/map.h17
1 files changed, 3 insertions, 14 deletions
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);