diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-06-29 12:58:57 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-06-29 12:58:57 +0300 |
commit | 9298f2a4e52d8b011b19331041455a45d57678b6 (patch) | |
tree | e60a89f4ef6ed4a75c79adc49250602a386e169a /src/Accelerometers/Accelerometers.cpp | |
parent | 60a2067eaac8fa64473c3068caaca5e7902817d7 (diff) |
Refactored swap-and-delete operations
Diffstat (limited to 'src/Accelerometers/Accelerometers.cpp')
-rw-r--r-- | src/Accelerometers/Accelerometers.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/Accelerometers/Accelerometers.cpp b/src/Accelerometers/Accelerometers.cpp index 43128ebd..c2a5d982 100644 --- a/src/Accelerometers/Accelerometers.cpp +++ b/src/Accelerometers/Accelerometers.cpp @@ -409,9 +409,7 @@ GCodeResult Accelerometers::ConfigureAccelerometer(GCodeBuffer& gb, const String seen = true; // Creating a new accelerometer. First delete any existing accelerometer. - LIS3DH *temp = nullptr; - std::swap(temp, accelerometer); - delete temp; + DeleteObject(accelerometer); spiCsPort.Release(); irqPort.Release(); @@ -424,7 +422,7 @@ GCodeResult Accelerometers::ConfigureAccelerometer(GCodeBuffer& gb, const String } const uint32_t spiFrequency = (gb.Seen('Q')) ? gb.GetLimitedUIValue('Q', 500000, 10000001) : DefaultAccelerometerSpiFrequency; - temp = new LIS3DH(SharedSpiDevice::GetMainSharedSpiDevice(), spiFrequency, spiCsPort.GetPin(), irqPort.GetPin()); + auto temp = new LIS3DH(SharedSpiDevice::GetMainSharedSpiDevice(), spiFrequency, spiCsPort.GetPin(), irqPort.GetPin()); if (temp->CheckPresent()) { accelerometer = temp; |