Table: Add clone constructor (and bind in MRI)

Fixes #50.
This commit is contained in:
Jonas Kulla 2014-08-04 14:43:56 +02:00
parent 59aed37d3e
commit 151a1f0d1b
3 changed files with 12 additions and 0 deletions

View file

@ -36,6 +36,14 @@ Table::Table(int x, int y /*= 1*/, int z /*= 1*/)
data = static_cast<int16_t*>(calloc(x * y * z, sizeof(int16_t)));
}
Table::Table(const Table &other)
:m_x(other.m_x), m_y(other.m_y), m_z(other.m_z)
{
const size_t size = m_x * m_y * m_z * sizeof(int16_t);;
data = static_cast<int16_t*>(malloc(size));
memcpy(data, other.data, size);
}
Table::~Table()
{
free(data);

View file

@ -31,6 +31,8 @@ class Table : public Serializable
{
public:
Table(int x, int y = 1, int z = 1);
/* Clone constructor */
Table(const Table &other);
virtual ~Table();
int xSize() const { return m_x; }