Skip to content

Commit f9e4311

Browse files
authored
Merge pull request #136 from sparkfun/release_candidate
v2.2.9 - add a destructor to resolve issue #135
2 parents 7ab87ae + 020bd9e commit f9e4311

3 files changed

+29
-1
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.2.8
2+
version=2.2.9
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,40 @@ SFE_UBLOX_GNSS::SFE_UBLOX_GNSS(void)
6363
#endif
6464
}
6565

66+
SFE_UBLOX_GNSS::~SFE_UBLOX_GNSS(void)
67+
{
68+
// Destructor
69+
70+
end(); // Delete all allocated memory - excluding payloadCfg, payloadAuto and spiBuffer
71+
72+
if (payloadCfg != NULL)
73+
{
74+
delete[] payloadCfg; // Created with new[]
75+
payloadCfg = NULL; // Redundant?
76+
}
77+
78+
if (payloadAuto != NULL)
79+
{
80+
delete[] payloadAuto; // Created with new[]
81+
payloadAuto = NULL; // Redundant?
82+
}
83+
84+
if (spiBuffer != NULL)
85+
{
86+
delete[] spiBuffer; // Created with new[]
87+
spiBuffer = NULL; // Redundant?
88+
}
89+
}
90+
6691
// Stop all automatic message processing. Free all used RAM
6792
void SFE_UBLOX_GNSS::end(void)
6893
{
6994
// Note: payloadCfg is not deleted
7095

7196
// Note: payloadAuto is not deleted
7297

98+
// Note: spiBuffer is not deleted
99+
73100
if (ubxFileBuffer != NULL) // Check if RAM has been allocated for the file buffer
74101
{
75102
#ifndef SFE_UBLOX_REDUCED_PROG_MEM

src/SparkFun_u-blox_GNSS_Arduino_Library.h

+1
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ class SFE_UBLOX_GNSS
643643
{
644644
public:
645645
SFE_UBLOX_GNSS(void);
646+
~SFE_UBLOX_GNSS(void);
646647

647648
// A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB.
648649
// If you know you are only going to be using I2C / Qwiic communication, you can

0 commit comments

Comments
 (0)