Skip to content

Commit

Permalink
provide a defaulted optional 'exact' switch to resize to force a resi…
Browse files Browse the repository at this point in the history
…ze of the PointBuffer even if current capcity is larger than the requested capacity
  • Loading branch information
hobu committed Mar 17, 2013
1 parent b911109 commit da1818e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/pdal/PointBuffer.hpp
Expand Up @@ -301,7 +301,7 @@ class PDAL_DLL PointBuffer
return m_metadata;
}

void resize(boost::uint32_t const& capacity);
void resize(boost::uint32_t const& capacity, bool bExact=false);

/** @name Serialization
*/
Expand Down
4 changes: 2 additions & 2 deletions src/PointBuffer.cpp
Expand Up @@ -118,13 +118,13 @@ void PointBuffer::reset(Schema const& new_schema)

}

void PointBuffer::resize(boost::uint32_t const& capacity)
void PointBuffer::resize(boost::uint32_t const& capacity, bool bExact)
{
if (capacity != m_capacity)
{
m_capacity = capacity;
boost::uint64_t new_array_size = static_cast<boost::uint64_t>(m_schema.getByteSize()) * static_cast<boost::uint64_t>(m_capacity);
if (new_array_size > m_arraySize)
if (new_array_size > m_arraySize || bExact)
{
boost::uint8_t* new_array = new boost::uint8_t[ new_array_size ]();
m_data.reset(new_array);
Expand Down

0 comments on commit da1818e

Please sign in to comment.