Merge pull request #40 from jgfoster/memory_leak
Release memory allocated in constructor to avoid memory leak
This commit is contained in:
commit
a8c9c5183c
|
|
@ -70,6 +70,16 @@ Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
|
||||||
_spi = NULL;
|
_spi = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Release memory allocated in constructors
|
||||||
|
*/
|
||||||
|
Adafruit_SPIDevice::~Adafruit_SPIDevice() {
|
||||||
|
if (_spiSetting) {
|
||||||
|
delete _spiSetting;
|
||||||
|
_spiSetting = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes SPI bus and sets CS pin high
|
* @brief Initializes SPI bus and sets CS pin high
|
||||||
* @return Always returns true because there's no way to test success of SPI
|
* @return Always returns true because there's no way to test success of SPI
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ public:
|
||||||
uint32_t freq = 1000000,
|
uint32_t freq = 1000000,
|
||||||
BitOrder dataOrder = SPI_BITORDER_MSBFIRST,
|
BitOrder dataOrder = SPI_BITORDER_MSBFIRST,
|
||||||
uint8_t dataMode = SPI_MODE0);
|
uint8_t dataMode = SPI_MODE0);
|
||||||
|
~Adafruit_SPIDevice();
|
||||||
|
|
||||||
bool begin(void);
|
bool begin(void);
|
||||||
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);
|
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue