aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-04-25 19:22:07 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-04-25 19:22:11 +0200
commit541496b65b366f846682c930aad4dbd66c97be89 (patch)
tree6064cb0b52348bd9e4206adf02c013b06882522a
parentc785fb130a0ae4e5ae23ccc7817d03c551cf8fdc (diff)
lms: flush_recv: alloc buf on stack instead of heap
No need to use the heap here since buffer is only used as a temporary trash. Using the stack is quicker. Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
-rw-r--r--Transceiver52M/device/lms/LMSDevice.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 05904e8..064d742 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -450,7 +450,7 @@ bool LMSDevice::flush_recv(size_t num_pkts)
{
#define CHUNK 625
int len = CHUNK * tx_sps;
- short *buffer = new short[len * 2];
+ short *buffer = (short*) alloca(sizeof(short) * len * 2);
int rc;
lms_stream_meta_t rx_metadata = {};
rx_metadata.flushPartialPacket = false;
@@ -463,7 +463,6 @@ bool LMSDevice::flush_recv(size_t num_pkts)
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at " << std::hex << rx_metadata.timestamp;
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
- delete[] buffer;
return false;
}
@@ -471,7 +470,6 @@ bool LMSDevice::flush_recv(size_t num_pkts)
}
LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
- delete[] buffer;
return true;
}