Release memory allocated in constructors

This commit is contained in:
James Foster 2020-11-30 15:47:49 -08:00
parent bbb893f51d
commit 3fc89c5835
2 changed files with 9 additions and 0 deletions

View File

@ -70,6 +70,14 @@ Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
_spi = NULL;
}
// release memory allocated in constructors
Adafruit_SPIDevice::~Adafruit_SPIDevice() {
if (_spiSetting) {
delete _spiSetting;
_spiSetting = nullptr;
}
}
/*!
* @brief Initializes SPI bus and sets CS pin high
* @return Always returns true because there's no way to test success of SPI

View File

@ -64,6 +64,7 @@ public:
uint32_t freq = 1000000,
BitOrder dataOrder = SPI_BITORDER_MSBFIRST,
uint8_t dataMode = SPI_MODE0);
~Adafruit_SPIDevice();
bool begin(void);
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);