projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add initial NSIS file for building a win installer.
[pulseview.git]
/
datasnapshot.cpp
diff --git
a/datasnapshot.cpp
b/datasnapshot.cpp
index 1a6376882286760b36a9be7acb8827312ef74a3e..6933ea12b9440623884e8b9dc18edada1aac7d35 100644
(file)
--- a/
datasnapshot.cpp
+++ b/
datasnapshot.cpp
@@
-1,5
+1,5
@@
/*
/*
- * 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>
*
*
* Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
*
@@
-20,12
+20,32
@@
#include "datasnapshot.h"
#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;
}
}
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;
+}