* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "segment.hpp"
return sample_count_;
}
-double Segment::start_time() const
+const pv::util::Timestamp& Segment::start_time() const
{
return start_time_;
}
assert(capacity_ >= sample_count_);
if (new_capacity > capacity_) {
- capacity_ = new_capacity;
+ // If we're out of memory, this will throw std::bad_alloc
data_.resize((new_capacity * unit_size_) + sizeof(uint64_t));
+ capacity_ = new_capacity;
}
}
// Ensure there's enough capacity to copy.
const uint64_t free_space = capacity_ - sample_count_;
- if (free_space < samples) {
+ if (free_space < samples)
set_capacity(sample_count_ + samples);
- }
memcpy((uint8_t*)data_.data() + sample_count_ * unit_size_,
data, samples * unit_size_);