mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 801466 - part 3 1/2 remove some prmem usage from dom/ and docshell/ r=mounir
This commit is contained in:
parent
aaa9a6c9d8
commit
bd2d1feb84
@ -161,7 +161,6 @@
|
|||||||
#include "nsIJARChannel.h"
|
#include "nsIJARChannel.h"
|
||||||
|
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
#include "prmem.h"
|
|
||||||
|
|
||||||
#include "nsISelectionDisplay.h"
|
#include "nsISelectionDisplay.h"
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
// Helper Classes
|
// Helper Classes
|
||||||
#include "nsXPIDLString.h"
|
#include "nsXPIDLString.h"
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "prmem.h"
|
|
||||||
#include "jsapi.h" // for JSAutoRequest
|
#include "jsapi.h" // for JSAutoRequest
|
||||||
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
|
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
|
||||||
#include "jsfriendapi.h" // for JS_GetGlobalForFrame
|
#include "jsfriendapi.h" // for JS_GetGlobalForFrame
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
#include "nsIObjectInputStream.h"
|
#include "nsIObjectInputStream.h"
|
||||||
#include "nsIObjectOutputStream.h"
|
#include "nsIObjectOutputStream.h"
|
||||||
#include "nsDOMScriptObjectHolder.h"
|
#include "nsDOMScriptObjectHolder.h"
|
||||||
#include "prmem.h"
|
|
||||||
#include "WrapperFactory.h"
|
#include "WrapperFactory.h"
|
||||||
#include "nsGlobalWindow.h"
|
#include "nsGlobalWindow.h"
|
||||||
#include "nsScriptNameSpaceManager.h"
|
#include "nsScriptNameSpaceManager.h"
|
||||||
@ -4106,24 +4105,18 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
JSContext *mContext;
|
JSContext *mContext;
|
||||||
jsval *mArgv;
|
FallibleTArray<jsval> mArgv;
|
||||||
uint32_t mArgc;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv,
|
nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv,
|
||||||
nsresult *prv) :
|
nsresult *prv) :
|
||||||
mContext(aContext),
|
mContext(aContext)
|
||||||
mArgv(nullptr),
|
|
||||||
mArgc(argc)
|
|
||||||
{
|
{
|
||||||
// copy the array - we don't know its lifetime, and ours is tied to xpcom
|
// copy the array - we don't know its lifetime, and ours is tied to xpcom
|
||||||
// refcounting. Alloc zero'd array so cleanup etc is safe.
|
// refcounting. Alloc zero'd array so cleanup etc is safe.
|
||||||
if (argc) {
|
if (!mArgv.EnsureLengthAtLeast(argc)) {
|
||||||
mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
|
*prv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
if (!mArgv) {
|
return;
|
||||||
*prv = NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callers are allowed to pass in a null argv even for argc > 0. They can
|
// Callers are allowed to pass in a null argv even for argc > 0. They can
|
||||||
@ -4148,13 +4141,10 @@ nsJSArgArray::~nsJSArgArray()
|
|||||||
void
|
void
|
||||||
nsJSArgArray::ReleaseJSObjects()
|
nsJSArgArray::ReleaseJSObjects()
|
||||||
{
|
{
|
||||||
if (mArgv) {
|
if (!mArgv.IsEmpty())
|
||||||
PR_DELETE(mArgv);
|
|
||||||
}
|
|
||||||
if (mArgc > 0) {
|
|
||||||
mArgc = 0;
|
|
||||||
NS_DROP_JS_OBJECTS(this, nsJSArgArray);
|
NS_DROP_JS_OBJECTS(this, nsJSArgArray);
|
||||||
}
|
|
||||||
|
mArgv.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryInterface implementation for nsJSArgArray
|
// QueryInterface implementation for nsJSArgArray
|
||||||
@ -4167,12 +4157,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSArgArray)
|
|||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray)
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray)
|
||||||
jsval *argv = tmp->mArgv;
|
uint32_t length = tmp->mArgv.Length();
|
||||||
if (argv) {
|
for (uint32_t i = 0; i < length; i++) {
|
||||||
jsval *end;
|
if (JSVAL_IS_GCTHING(tmp->mArgv[i])) {
|
||||||
for (end = argv + tmp->mArgc; argv < end; ++argv) {
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(JSVAL_TO_GCTHING(tmp->mArgv[i]),
|
||||||
if (JSVAL_IS_GCTHING(*argv))
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(JSVAL_TO_GCTHING(*argv),
|
|
||||||
"mArgv[i]")
|
"mArgv[i]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4190,15 +4178,15 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSArgArray)
|
|||||||
nsresult
|
nsresult
|
||||||
nsJSArgArray::GetArgs(uint32_t *argc, void **argv)
|
nsJSArgArray::GetArgs(uint32_t *argc, void **argv)
|
||||||
{
|
{
|
||||||
*argv = (void *)mArgv;
|
*argv = (void *)mArgv.Elements();
|
||||||
*argc = mArgc;
|
*argc = mArgv.Length();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIArray impl
|
// nsIArray impl
|
||||||
NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
|
NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
|
||||||
{
|
{
|
||||||
*aLength = mArgc;
|
*aLength = mArgv.Length();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4206,7 +4194,7 @@ NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
|
|||||||
NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, void * *result)
|
NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, void * *result)
|
||||||
{
|
{
|
||||||
*result = nullptr;
|
*result = nullptr;
|
||||||
if (index >= mArgc)
|
if (index >= mArgv.Length())
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
if (uuid.Equals(NS_GET_IID(nsIVariant)) || uuid.Equals(NS_GET_IID(nsISupports))) {
|
if (uuid.Equals(NS_GET_IID(nsIVariant)) || uuid.Equals(NS_GET_IID(nsISupports))) {
|
||||||
|
@ -191,7 +191,7 @@ ArchiveReaderZipEvent::Exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the name:
|
// Read the name:
|
||||||
char* filename = (char*)PR_Malloc(filenameLen + 1);
|
nsAutoArrayPtr<char> filename(new char[filenameLen + 1]);
|
||||||
rv = inputStream->Read(filename, filenameLen, &ret);
|
rv = inputStream->Read(filename, filenameLen, &ret);
|
||||||
if (NS_FAILED(rv) || ret != filenameLen) {
|
if (NS_FAILED(rv) || ret != filenameLen) {
|
||||||
return RunShare(NS_ERROR_UNEXPECTED);
|
return RunShare(NS_ERROR_UNEXPECTED);
|
||||||
@ -204,8 +204,6 @@ ArchiveReaderZipEvent::Exec()
|
|||||||
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mOptions));
|
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_Free(filename);
|
|
||||||
|
|
||||||
// Ignore the rest
|
// Ignore the rest
|
||||||
seekableStream->Seek(nsISeekableStream::NS_SEEK_CUR, extraLen + commentLen);
|
seekableStream->Seek(nsISeekableStream::NS_SEEK_CUR, extraLen + commentLen);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsDependentString.h"
|
#include "nsDependentString.h"
|
||||||
#include "prmem.h"
|
|
||||||
#include "nsArrayEnumerator.h"
|
#include "nsArrayEnumerator.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user