Locale kit: Fix PVS 550, 551
Use BStackOrHeapArray instead of applying auto_ptr to array. Change-Id: I204dcb97a1bc2d047783bc6015f86b36ca0cc15b Reviewed-on: https://review.haiku-os.org/725 Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
6f1cd477d4
commit
26b2733af3
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <new>
|
||||
|
||||
#include <AppFileInfo.h>
|
||||
@ -23,14 +23,15 @@
|
||||
#include <Path.h>
|
||||
#include <Resources.h>
|
||||
#include <Roster.h>
|
||||
#include <StackOrHeapArray.h>
|
||||
|
||||
#include <DefaultCatalog.h>
|
||||
#include <MutableLocaleRoster.h>
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
using std::auto_ptr;
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::pair;
|
||||
@ -205,15 +206,15 @@ DefaultCatalog::ReadFromFile(const char *path)
|
||||
return res;
|
||||
}
|
||||
|
||||
auto_ptr<char> buf(new(std::nothrow) char [sz]);
|
||||
if (buf.get() == NULL)
|
||||
BStackOrHeapArray<char, 0> buf(sz);
|
||||
if (!buf.IsValid())
|
||||
return B_NO_MEMORY;
|
||||
res = catalogFile.Read(buf.get(), sz);
|
||||
res = catalogFile.Read(buf, sz);
|
||||
if (res < B_OK)
|
||||
return res;
|
||||
if (res < sz)
|
||||
return res;
|
||||
BMemoryIO memIO(buf.get(), sz);
|
||||
BMemoryIO memIO(buf, sz);
|
||||
res = Unflatten(&memIO);
|
||||
|
||||
if (res == B_OK) {
|
||||
@ -246,15 +247,15 @@ DefaultCatalog::ReadFromAttribute(const entry_ref &appOrAddOnRef)
|
||||
return B_BAD_TYPE;
|
||||
|
||||
size_t size = attrInfo.size;
|
||||
auto_ptr<char> buf(new(std::nothrow) char [size]);
|
||||
if (buf.get() == NULL)
|
||||
BStackOrHeapArray<char, 0> buf(size);
|
||||
if (!buf.IsValid())
|
||||
return B_NO_MEMORY;
|
||||
res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
|
||||
buf.get(), size);
|
||||
buf, size);
|
||||
if (res < (ssize_t)size)
|
||||
return res < B_OK ? res : B_BAD_DATA;
|
||||
|
||||
BMemoryIO memIO(buf.get(), size);
|
||||
BMemoryIO memIO(buf, size);
|
||||
res = Unflatten(&memIO);
|
||||
|
||||
return res;
|
||||
|
Loading…
x
Reference in New Issue
Block a user