mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Data:clone ported to minor
minor tweaks --HG-- branch : minor
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user