Skip to content

Commit c38129d

Browse files
author
James Foster
authored
Use arduino_ci GitHub Action; fix destructor (#8)
* Update to use new `arduino_ci` GitHub Action * Move destructor out of header; remove extra delete.
1 parent 5534b75 commit c38129d

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.github/workflows/arduino_ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
arduino_ci:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: Arduino-CI/action@v0.1.0

scripts/testAndBuild.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#! /bin/sh
22
bundle config --local path vendor/bundle
33
bundle install
4-
bundle exec arduino_ci.rb --skip-examples-compilation
4+
bundle exec arduino_ci.rb

src/Adafruit_SPIDevice.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin,
7575
_spi = NULL;
7676
}
7777

78+
// Release memory allocated in constructors
79+
Adafruit_SPIDevice::~Adafruit_SPIDevice() {
80+
if (_spiSetting) {
81+
delete _spiSetting;
82+
_spiSetting = nullptr;
83+
}
84+
}
85+
7886
/*!
7987
* @brief Initializes SPI bus and sets CS pin high
8088
* @return Always returns true because there's no way to test success of SPI

src/Adafruit_SPIDevice.h

+1-11
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,7 @@ class Adafruit_SPIDevice {
6464
uint32_t freq = 1000000,
6565
BitOrder dataOrder = SPI_BITORDER_MSBFIRST,
6666
uint8_t dataMode = SPI_MODE0);
67-
68-
~Adafruit_SPIDevice() {
69-
if (_spi) {
70-
delete _spi;
71-
_spi = nullptr;
72-
}
73-
if (_spiSetting) {
74-
delete _spiSetting;
75-
_spiSetting = nullptr;
76-
}
77-
}
67+
~Adafruit_SPIDevice();
7868

7969
bool begin(void);
8070
bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF);

0 commit comments

Comments
 (0)