/*
- * This file is part of the sigrok project.
+ * This file is part of the PulseView project.
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
*
#include "datasnapshot.h"
-DataSnapshot::DataSnapshot() :
- _sample_count(0)
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+DataSnapshot::DataSnapshot(int unit_size) :
+ _data(NULL),
+ _sample_count(0),
+ _unit_size(unit_size)
+{
+ assert(_unit_size > 0);
+}
+
+DataSnapshot::~DataSnapshot()
{
+ free(_data);
}
uint64_t DataSnapshot::get_sample_count()
{
return _sample_count;
}
+
+void DataSnapshot::append_data(void *data, uint64_t samples)
+{
+ _data = realloc(_data, (_sample_count + samples) * _unit_size);
+ memcpy((uint8_t*)_data + _sample_count * _unit_size,
+ data, samples * _unit_size);
+ _sample_count += samples;
+}