Fix unique_ptr usage

This commit is contained in:
Nekotekina 2015-04-21 22:35:11 +03:00
parent 978d578f4e
commit 8b0c772423
3 changed files with 5 additions and 5 deletions

View File

@ -10,13 +10,13 @@
#define GET_API_ERROR static_cast<u64>(GetLastError())
std::unique_ptr<wchar_t> ConvertUTF8ToWChar(const std::string& source)
std::unique_ptr<wchar_t[]> ConvertUTF8ToWChar(const std::string& source)
{
const size_t length = source.size() + 1; // size + null terminator
const int size = source.size() < INT_MAX ? static_cast<int>(length) : throw std::length_error(__FUNCTION__);
std::unique_ptr<wchar_t> buffer(new wchar_t[length]); // allocate buffer assuming that length is the max possible size
std::unique_ptr<wchar_t[]> buffer(new wchar_t[length]); // allocate buffer assuming that length is the max possible size
if (!MultiByteToWideChar(CP_UTF8, 0, source.c_str(), size, buffer.get(), size))
{

View File

@ -711,7 +711,7 @@ s32 cellVdecGetPicture(u32 handle, vm::ptr<const CellVdecPicFormat> format, vm::
auto out_f = AV_PIX_FMT_YUV420P;
std::unique_ptr<u8> alpha_plane;
std::unique_ptr<u8[]> alpha_plane;
switch (const u32 type = format->formatType)
{

View File

@ -46,7 +46,7 @@ bool PSFLoader::Load(vfsStream& stream)
const u32 key_table_size = header.off_data_table - header.off_key_table;
std::unique_ptr<char> keys(new char[key_table_size + 1]);
std::unique_ptr<char[]> keys(new char[key_table_size + 1]);
stream.Seek(header.off_key_table);
@ -91,7 +91,7 @@ bool PSFLoader::Load(vfsStream& stream)
const u32 size = indices[i].param_len;
std::unique_ptr<char> str(new char[size + 1]);
std::unique_ptr<char[]> str(new char[size + 1]);
if (stream.Read(str.get(), size) != size)
{