Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Fri Apr 26 16:51:14 UTC 2019


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/13782 )

Change subject: lms: flush_recv: alloc buf on stack instead of heap
......................................................................

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
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 1 insertion(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



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 @@
 {
 	#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 @@
 		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 @@
 	}
 
 	LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
-	delete[] buffer;
 	return true;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-CC: Max <suraev at alumni.ntnu.no>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190426/a102ecf0/attachment.htm>


More information about the gerrit-log mailing list