tools/locale: Fix using auto_ptr to array.

Use BStackOrHeapArray instead of using auto_ptr to array.

Change-Id: I171cb002829c36ec51ba7d1e387869263e2a40f2
Reviewed-on: https://review.haiku-os.org/745
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Murai Takashi
2018-12-02 21:31:26 +00:00
committed by waddlesplash
parent 6439130107
commit 4c5e5d8b04
3 changed files with 48 additions and 8 deletions
@@ -0,0 +1,43 @@
/*
* Copyright 2012, Jonathan Schleifer <[email protected]>. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SUPPORT_STACKORHEAPARRAY_H
#define _SUPPORT_STACKORHEAPARRAY_H
#include <cstddef>
#include <new>
template <typename Type, int StackSize>
class BStackOrHeapArray {
public:
BStackOrHeapArray(size_t count)
{
if (count > StackSize)
fData = new(std::nothrow) Type[count];
else
fData = fStackData;
}
~BStackOrHeapArray()
{
if (fData != fStackData)
delete[] fData;
}
bool IsValid() const
{
return fData != NULL;
}
operator Type*()
{
return fData;
}
private:
Type fStackData[StackSize];
Type* fData;
};
#endif