mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
e368dc9c85
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
88 lines
2.1 KiB
C++
88 lines
2.1 KiB
C++
/* 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
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsHtml5OwningUTF16Buffer.h"
|
|
|
|
nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(PRUnichar* aBuffer)
|
|
: nsHtml5UTF16Buffer(aBuffer, 0),
|
|
next(nullptr),
|
|
key(nullptr)
|
|
{
|
|
MOZ_COUNT_CTOR(nsHtml5OwningUTF16Buffer);
|
|
}
|
|
|
|
nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(void* aKey)
|
|
: nsHtml5UTF16Buffer(nullptr, 0),
|
|
next(nullptr),
|
|
key(aKey)
|
|
{
|
|
MOZ_COUNT_CTOR(nsHtml5OwningUTF16Buffer);
|
|
}
|
|
|
|
nsHtml5OwningUTF16Buffer::~nsHtml5OwningUTF16Buffer()
|
|
{
|
|
MOZ_COUNT_DTOR(nsHtml5OwningUTF16Buffer);
|
|
DeleteBuffer();
|
|
|
|
// This is to avoid dtor recursion on 'next', bug 706932.
|
|
nsRefPtr<nsHtml5OwningUTF16Buffer> tail;
|
|
tail.swap(next);
|
|
while (tail && tail->mRefCnt == 1) {
|
|
nsRefPtr<nsHtml5OwningUTF16Buffer> tmp;
|
|
tmp.swap(tail->next);
|
|
tail.swap(tmp);
|
|
}
|
|
}
|
|
|
|
// static
|
|
already_AddRefed<nsHtml5OwningUTF16Buffer>
|
|
nsHtml5OwningUTF16Buffer::FalliblyCreate(int32_t aLength)
|
|
{
|
|
const mozilla::fallible_t fallible = mozilla::fallible_t();
|
|
PRUnichar* newBuf = new (fallible) PRUnichar[aLength];
|
|
if (!newBuf) {
|
|
return nullptr;
|
|
}
|
|
nsRefPtr<nsHtml5OwningUTF16Buffer> newObj =
|
|
new (fallible) nsHtml5OwningUTF16Buffer(newBuf);
|
|
if (!newObj) {
|
|
delete[] newBuf;
|
|
return nullptr;
|
|
}
|
|
return newObj.forget();
|
|
}
|
|
|
|
void
|
|
nsHtml5OwningUTF16Buffer::Swap(nsHtml5OwningUTF16Buffer* aOther)
|
|
{
|
|
nsHtml5UTF16Buffer::Swap(aOther);
|
|
}
|
|
|
|
|
|
// Not using macros for AddRef and Release in order to be able to refcount on
|
|
// and create on different threads.
|
|
|
|
nsrefcnt
|
|
nsHtml5OwningUTF16Buffer::AddRef()
|
|
{
|
|
NS_PRECONDITION(int32_t(mRefCnt) >= 0, "Illegal refcount.");
|
|
++mRefCnt;
|
|
NS_LOG_ADDREF(this, mRefCnt, "nsHtml5OwningUTF16Buffer", sizeof(*this));
|
|
return mRefCnt;
|
|
}
|
|
|
|
nsrefcnt
|
|
nsHtml5OwningUTF16Buffer::Release()
|
|
{
|
|
NS_PRECONDITION(0 != mRefCnt, "Release without AddRef.");
|
|
--mRefCnt;
|
|
NS_LOG_RELEASE(this, mRefCnt, "nsHtml5OwningUTF16Buffer");
|
|
if (mRefCnt == 0) {
|
|
mRefCnt = 1; /* stabilize */
|
|
delete this;
|
|
return 0;
|
|
}
|
|
return mRefCnt;
|
|
}
|