mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1252153 - use UniquePtr instead of ScopedDeletePtr in HeapCopyOfStackArray; r=jrmuizel
UniquePtr is more standard than ScopedDeletePtr; using standard constructs whenever possible is preferable.
This commit is contained in:
parent
d78dff1308
commit
6387200fc8
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -8,7 +8,7 @@
|
||||
#define HEAPCOPYOFSTACKARRAY_H_
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Scoped.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -25,12 +25,12 @@ public:
|
||||
template<size_t N>
|
||||
MOZ_IMPLICIT HeapCopyOfStackArray(ElemType (&array)[N])
|
||||
: mArrayLength(N)
|
||||
, mArrayData(new ElemType[N])
|
||||
, mArrayData(MakeUnique<ElemType[]>(N))
|
||||
{
|
||||
memcpy(mArrayData, &array[0], N * sizeof(ElemType));
|
||||
memcpy(mArrayData.get(), &array[0], N * sizeof(ElemType));
|
||||
}
|
||||
|
||||
ElemType* Data() const { return mArrayData; }
|
||||
ElemType* Data() const { return mArrayData.get(); }
|
||||
size_t ArrayLength() const { return mArrayLength; }
|
||||
size_t ByteLength() const { return mArrayLength * sizeof(ElemType); }
|
||||
|
||||
@ -39,7 +39,7 @@ private:
|
||||
HeapCopyOfStackArray(const HeapCopyOfStackArray&) = delete;
|
||||
|
||||
const size_t mArrayLength;
|
||||
ScopedDeletePtr<ElemType> const mArrayData;
|
||||
UniquePtr<ElemType[]> const mArrayData;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user