[PATCH] osmo-trx[master]: vector: Introduce shrink() function to shrink vector size wi...

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/.

Alexander Chemeris gerrit-no-reply at lists.osmocom.org
Wed Mar 22 18:44:20 UTC 2017


Review at  https://gerrit.osmocom.org/2157

vector: Introduce shrink() function to shrink vector size without loosing data.

Change-Id: I9c0ac2715aea1a90c9e6ebcd982522b80a547099
---
M CommonLibs/Vector.h
1 file changed, 7 insertions(+), 0 deletions(-)


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

diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h
index bb4d352..c66522b 100644
--- a/CommonLibs/Vector.h
+++ b/CommonLibs/Vector.h
@@ -92,6 +92,13 @@
 		mEnd = mStart + newSize;
 	}
 
+	/** Reduce addressable size of the Vector, keeping content. */
+	void shrink(size_t newSize)
+	{
+		assert(newSize <= mEnd - mStart);
+		mEnd = mStart + newSize;
+	}
+
 	/** Release memory and clear pointers. */
 	void clear() { resize(0); }
 

-- 
To view, visit https://gerrit.osmocom.org/2157
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c0ac2715aea1a90c9e6ebcd982522b80a547099
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Alexander Chemeris <Alexander.Chemeris at gmail.com>



More information about the gerrit-log mailing list