From 897d2fb1fb3676ee320382acd2e86b0250cd7420 Mon Sep 17 00:00:00 2001 From: Staroselskii Georgii Date: Thu, 7 Jul 2016 16:44:05 +0300 Subject: [PATCH] AP_HAL_Linux: use OwnPtr for _device in UARTDriver Otherwise we're going to leak memory without any need. Before this fix we've created ConsoleDevice 4 times in case -A switch hadn't been supplied, but we hadn't ever deleted those. Now there's no memory leak here. --- libraries/AP_HAL_Linux/UARTDriver.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_Linux/UARTDriver.h b/libraries/AP_HAL_Linux/UARTDriver.h index 3b26c4057a..0339712184 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.h +++ b/libraries/AP_HAL_Linux/UARTDriver.h @@ -1,7 +1,8 @@ #pragma once -#include "AP_HAL_Linux.h" +#include +#include "AP_HAL_Linux.h" #include "SerialDevice.h" class Linux::UARTDriver : public AP_HAL::UARTDriver { @@ -38,7 +39,7 @@ public: enum flow_control get_flow_control(void) { return _flow_control; } private: - SerialDevice *_device = nullptr; + AP_HAL::OwnPtr _device; bool _nonblocking_writes; bool _console; volatile bool _in_timer;