Data:clone ported to minor

minor tweaks

--HG--
branch : minor
This commit is contained in:
Raidho
2017-02-10 06:19:53 +03:00
parent bc6a2db22f
commit 6ea1ebde9c
22 changed files with 203 additions and 0 deletions
+23
View File
@@ -56,11 +56,34 @@ FileData::FileData(uint64 size, const std::string &filename)
name = filename;
}
FileData::FileData(const FileData &c)
: data(nullptr)
, size(c.size)
, filename(c.filename)
, extension(c.extension)
, name(c.name)
{
try
{
data = new char[(size_t) size];
}
catch (std::bad_alloc &)
{
throw love::Exception("Out of memory.");
}
memcpy(data, c.data, size);
}
FileData::~FileData()
{
delete [] data;
}
Data *FileData::clone() const
{
return new FileData(*this);
}
void *FileData::getData() const
{
return data;