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.
This commit is contained in:
Staroselskii Georgii 2016-07-07 16:44:05 +03:00 committed by Lucas De Marchi
parent 3f1e999fc8
commit 897d2fb1fb

View File

@ -1,7 +1,8 @@
#pragma once
#include "AP_HAL_Linux.h"
#include <AP_HAL/utility/OwnPtr.h>
#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<SerialDevice> _device;
bool _nonblocking_writes;
bool _console;
volatile bool _in_timer;