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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Apr 25 21:27:44 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/82/13782/1

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: newchange
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190425/abf8286d/attachment.html>


More information about the gerrit-log mailing list