Bug 687744 and bug 573078 - Make buffer allocations in the HTML parser fallible; deal with allocation failures; reuse the buffers of strings passed to the parser. r=Olli.Pettay.
This commit is contained in:
@@ -35,24 +35,10 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
||||
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(PRInt32 size)
|
||||
: buffer(new PRUnichar[size]),
|
||||
start(0),
|
||||
end(0),
|
||||
next(nsnull),
|
||||
key(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsHtml5UTF16Buffer);
|
||||
}
|
||||
|
||||
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(void* key)
|
||||
: buffer(nsnull),
|
||||
start(0),
|
||||
end(0),
|
||||
next(nsnull),
|
||||
key(key)
|
||||
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(PRUnichar* aBuffer, PRInt32 aEnd)
|
||||
: buffer(aBuffer)
|
||||
, start(0)
|
||||
, end(aEnd)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsHtml5UTF16Buffer);
|
||||
}
|
||||
@@ -60,31 +46,10 @@ nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(void* key)
|
||||
nsHtml5UTF16Buffer::~nsHtml5UTF16Buffer()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsHtml5UTF16Buffer);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5UTF16Buffer::DeleteBuffer()
|
||||
{
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// Not using macros for AddRef and Release in order to be able to refcount on
|
||||
// and create on different threads.
|
||||
|
||||
nsrefcnt
|
||||
nsHtml5UTF16Buffer::AddRef()
|
||||
{
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "Illegal refcount.");
|
||||
++mRefCnt;
|
||||
NS_LOG_ADDREF(this, mRefCnt, "nsHtml5UTF16Buffer", sizeof(*this));
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsrefcnt
|
||||
nsHtml5UTF16Buffer::Release()
|
||||
{
|
||||
NS_PRECONDITION(0 != mRefCnt, "Release without AddRef.");
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsHtml5UTF16Buffer");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user