[Liblas-commits] hg: Fixed potential of doubled (or more)
allocation of CachedRea...
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Oct 20 20:28:17 EDT 2010
changeset 5a272a57945c in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5a272a57945c
summary: Fixed potential of doubled (or more) allocation of CachedReader::m_mas. Now, m_mask is allocated and initialised in single step and exact size, instead of growing incrementally. This fix is related to Gary's post http://lists.osgeo.org/pipermail/liblas-devel/2010-October/000992.html . Added FIXME comment.
diffstat:
src/detail/reader/cachedreader.cpp | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (20 lines):
diff -r a3489d26c8a3 -r 5a272a57945c src/detail/reader/cachedreader.cpp
--- a/src/detail/reader/cachedreader.cpp Tue Oct 19 14:59:45 2010 -0600
+++ b/src/detail/reader/cachedreader.cpp Thu Oct 21 01:28:06 2010 +0100
@@ -81,13 +81,13 @@
if (m_cache_size > hptr->GetPointRecordsCount()) {
m_cache_size = hptr->GetPointRecordsCount();
}
+ // FIXME: Note, vector::resize never shrinks the container and frees memory! Are we aware of this fact here? --mloskot
m_cache.resize(m_cache_size);
// Mark all positions as uncached and build up the mask
// to the size of the number of points in the file
- for (boost::uint32_t i = 0; i < hptr->GetPointRecordsCount(); ++i) {
- m_mask.push_back(0);
- }
+ boost::uint8_t const uncached_mask = 0;
+ cache_mask_type(hptr->GetPointRecordsCount(), uncached_mask).swap(m_mask);
return hptr;
}
More information about the Liblas-commits
mailing list