Add check for self-assignment
This commit is contained in:
parent
a5e2e58c36
commit
9a9e04d047
3 changed files with 24 additions and 18 deletions
src/protocols
|
@ -214,16 +214,18 @@ AX25Client::AX25Client(const AX25Client& ax25)
|
||||||
}
|
}
|
||||||
|
|
||||||
AX25Client& AX25Client::operator=(const AX25Client& ax25) {
|
AX25Client& AX25Client::operator=(const AX25Client& ax25) {
|
||||||
this->phyLayer = ax25.phyLayer;
|
if(&ax25 != this) {
|
||||||
this->sourceSSID = ax25.sourceSSID;
|
this->phyLayer = ax25.phyLayer;
|
||||||
this->preambleLen = ax25.preambleLen;
|
this->sourceSSID = ax25.sourceSSID;
|
||||||
strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1);
|
this->preambleLen = ax25.preambleLen;
|
||||||
#if !RADIOLIB_EXCLUDE_AFSK
|
strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1);
|
||||||
if(ax25.bellModem) {
|
#if !RADIOLIB_EXCLUDE_AFSK
|
||||||
this->audio = ax25.audio;
|
if(ax25.bellModem) {
|
||||||
this->bellModem = new BellClient(ax25.audio);
|
this->audio = ax25.audio;
|
||||||
|
this->bellModem = new BellClient(ax25.audio);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,11 @@ ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer(1, 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalRadio& ExternalRadio::operator=(const ExternalRadio& ext) {
|
ExternalRadio& ExternalRadio::operator=(const ExternalRadio& ext) {
|
||||||
this->prevFrf = ext.prevFrf;
|
if(&ext != this) {
|
||||||
if(ext.mod) {
|
this->prevFrf = ext.prevFrf;
|
||||||
this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio());
|
if(ext.mod) {
|
||||||
|
this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,14 @@ ITA2String::ITA2String(const ITA2String& ita2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ITA2String& ITA2String::operator=(const ITA2String& ita2) {
|
ITA2String& ITA2String::operator=(const ITA2String& ita2) {
|
||||||
this->asciiLen = ita2.asciiLen;
|
if(&ita2 != this) {
|
||||||
this->ita2Len = ita2.ita2Len;
|
this->asciiLen = ita2.asciiLen;
|
||||||
#if !RADIOLIB_STATIC_ONLY
|
this->ita2Len = ita2.ita2Len;
|
||||||
this->strAscii = new char[asciiLen + 1];
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
#endif
|
this->strAscii = new char[asciiLen + 1];
|
||||||
strcpy(this->strAscii, ita2.strAscii);
|
#endif
|
||||||
|
strcpy(this->strAscii, ita2.strAscii);
|
||||||
|
}
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue