Skip to content

Commit 4219ced

Browse files
authored
Merge pull request #10 from adamgarbo/master
Fix sensor reinitialization memory leak
2 parents 57854ba + ccc8fb1 commit 4219ced

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Adafruit_LSM303_Accel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Adafruit_LSM303_Accel_Unified::Adafruit_LSM303_Accel_Unified(int32_t sensorID) {
6868
*/
6969
bool Adafruit_LSM303_Accel_Unified::begin(uint8_t i2c_address, TwoWire *wire) {
7070

71+
if (i2c_dev)
72+
delete i2c_dev;
7173
i2c_dev = new Adafruit_I2CDevice(i2c_address, wire);
7274

7375
if (!i2c_dev->begin()) {

0 commit comments

Comments
 (0)