Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-06-29 10:57:12 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-06-29 10:57:12 +0300
commit60a2067eaac8fa64473c3068caaca5e7902817d7 (patch)
treed0d5d4328578a55ebc7321e8db548f7cb5e51aaa /src/RepRapFirmware.h
parent4872582d0c6f26fbf513e058ab5f26a06ccf7c50 (diff)
In PanelDueUpdater make sure we delete all objects we created
Diffstat (limited to 'src/RepRapFirmware.h')
-rw-r--r--src/RepRapFirmware.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h
index 475f9d6d..42977578 100644
--- a/src/RepRapFirmware.h
+++ b/src/RepRapFirmware.h
@@ -448,6 +448,14 @@ private:
bool running;
};
+// Function to delete an object and clear the pointer. Safe to call even if the pointer is already null.
+template <typename T> void DeleteAndClear(T*& ptr) noexcept
+{
+ T* p2 = nullptr;
+ std::swap(ptr, p2);
+ delete p2;
+}
+
// Common definitions used by more than one module
constexpr size_t XY_AXES = 2; // The number of Cartesian axes