Remove memory leak and other configuration funnies.

This commit is contained in:
Jonathan Naylor 2020-04-25 17:29:10 +01:00
parent 394ab8dfd1
commit 4fe1c11250
3 changed files with 8 additions and 11 deletions

8
FM.cpp
View File

@ -46,11 +46,11 @@ m_rxBoost(1U)
void CFM::samples(bool cos, q15_t* samples, uint8_t length) void CFM::samples(bool cos, q15_t* samples, uint8_t length)
{ {
uint8_t i = 0; if (!m_useCOS)
for (; i < length; i++) { cos = true;
if (!m_useCOS)
cos = true;
uint8_t i = 0U;
for (; i < length; i++) {
q15_t currentSample = samples[i];//save to a local variable to avoid indirection on every access q15_t currentSample = samples[i];//save to a local variable to avoid indirection on every access
CTCSSState ctcssState = m_ctcssRX.process(currentSample); CTCSSState ctcssState = m_ctcssRX.process(currentSample);

View File

@ -102,9 +102,7 @@ uint8_t CFMCTCSSTX::setParams(uint8_t frequency, uint8_t level)
m_length = entry->length; m_length = entry->length;
if (m_values) delete[] m_values;
delete[] m_values;
m_values = new q15_t[m_length]; m_values = new q15_t[m_length];
q15_t arg = 0; q15_t arg = 0;

View File

@ -92,7 +92,8 @@ m_lowLevel(0)
uint8_t CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t highLevel, uint8_t lowLevel) uint8_t CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t highLevel, uint8_t lowLevel)
{ {
m_poLen=0; m_poLen = 0U;
for (uint8_t i = 0U; text[i] != '\0'; i++) { for (uint8_t i = 0U; text[i] != '\0'; i++) {
for (uint8_t j = 0U; SYMBOL_LIST[j].c != 0U; j++) { for (uint8_t j = 0U; SYMBOL_LIST[j].c != 0U; j++) {
if (SYMBOL_LIST[j].c == text[i]) { if (SYMBOL_LIST[j].c == text[i]) {
@ -119,9 +120,7 @@ uint8_t CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency,
m_audioLen = 24000U / frequency; // In samples m_audioLen = 24000U / frequency; // In samples
if (m_audio) delete[] m_audio;
delete[] m_audio;
m_audio = new bool[m_audioLen]; m_audio = new bool[m_audioLen];
for (uint16_t i = 0U; i < m_audioLen; i++) { for (uint16_t i = 0U; i < m_audioLen; i++) {