Browse Source

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.
master
Staroselskii Georgii 9 years ago committed by Lucas De Marchi
parent
commit
897d2fb1fb
  1. 5
      libraries/AP_HAL_Linux/UARTDriver.h

5
libraries/AP_HAL_Linux/UARTDriver.h

@ -1,7 +1,8 @@ @@ -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: @@ -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;

Loading…
Cancel
Save