Skip to content

v1.1.1 - add the destructor #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun Swarm Satellite Arduino Library
version=1.1.0
version=1.1.1
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the Swarm M138 satellite modem<br/><br/>
Expand Down
23 changes: 21 additions & 2 deletions src/SparkFun_Swarm_Satellite_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ SWARM_M138::SWARM_M138(void)
_printDebug = false;
_checkUnsolicitedMsgReentrant = false;
_lastI2cCheck = millis();
_swarmBacklog = NULL;
commandError = NULL;

_swarmDateTimeCallback = NULL;
_swarmGpsJammingCallback = NULL;
Expand All @@ -52,6 +54,21 @@ SWARM_M138::SWARM_M138(void)

}

SWARM_M138::~SWARM_M138(void)
{
if (_swarmBacklog != NULL)
{
delete[] _swarmBacklog;
_swarmBacklog = NULL;
}

if (commandError != NULL)
{
delete[] commandError;
commandError = NULL;
}
}

#ifdef SWARM_M138_SOFTWARE_SERIAL_ENABLED
/**************************************************************************/
/*!
Expand Down Expand Up @@ -142,7 +159,8 @@ bool SWARM_M138::isConnected(void)
// Private: allocate memory for the serial buffers and clear it
bool SWARM_M138::initializeBuffers()
{
_swarmBacklog = new char[_RxBuffSize];
if (_swarmBacklog == NULL)
_swarmBacklog = new char[_RxBuffSize];
if (_swarmBacklog == NULL)
{
if (_printDebug == true)
Expand All @@ -151,7 +169,8 @@ bool SWARM_M138::initializeBuffers()
}
memset(_swarmBacklog, 0, _RxBuffSize);

commandError = new char[SWARM_M138_MAX_CMD_ERROR_LEN];
if (commandError == NULL)
commandError = new char[SWARM_M138_MAX_CMD_ERROR_LEN];
if (commandError == NULL)
{
if (_printDebug == true)
Expand Down
3 changes: 3 additions & 0 deletions src/SparkFun_Swarm_Satellite_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ class SWARM_M138
/** @brief Class to communicate with the Swarm M138 satellite modem */
SWARM_M138(void);

// Destructor
~SWARM_M138(void);

/** Begin -- initialize module and ensure it's connected */
#ifdef SWARM_M138_SOFTWARE_SERIAL_ENABLED
bool begin(SoftwareSerial &softSerial);
Expand Down