bug 801466 - part 3.2 remove some usage of prmem in content/ r=mounir, khuey

This commit is contained in:
Trevor Saunders 2012-12-05 17:20:57 -05:00
parent c538b0d243
commit da73fd4891
8 changed files with 14 additions and 38 deletions

View File

@ -17,7 +17,6 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIXMLHttpRequest.h"
#include "prmem.h"
#include "nsAutoPtr.h"
#include "mozilla/GuardObjects.h"
@ -409,7 +408,7 @@ protected:
sDataOwners = nullptr;
}
PR_Free(mData);
moz_free(mData);
}
static void EnsureMemoryReporterRegistered();

View File

@ -42,7 +42,6 @@
#include "xpcpublic.h"
#include "nsContentPolicyUtils.h"
#include "jsfriendapi.h"
#include "prmem.h"
#include "nsDOMFile.h"
#include "nsWrapperCacheInlines.h"
#include "nsDOMEventTargetHelper.h"

View File

@ -10,7 +10,6 @@
#include "nsAttrAndChildArray.h"
#include "nsMappedAttributeElement.h"
#include "prmem.h"
#include "prbit.h"
#include "nsString.h"
#include "nsHTMLStyleSheet.h"
@ -100,7 +99,7 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
Clear();
PR_Free(mImpl);
moz_free(mImpl);
}
nsIContent*
@ -616,11 +615,11 @@ nsAttrAndChildArray::Compact()
// Then resize or free buffer
uint32_t newSize = attrCount * ATTRSIZE + childCount;
if (!newSize && !mImpl->mMappedAttrs) {
PR_Free(mImpl);
moz_free(mImpl);
mImpl = nullptr;
}
else if (newSize < mImpl->mBufferSize) {
mImpl = static_cast<Impl*>(PR_Realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
mImpl = static_cast<Impl*>(moz_realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
mImpl->mBufferSize = newSize;
@ -757,7 +756,7 @@ nsAttrAndChildArray::GrowBy(uint32_t aGrowSize)
}
bool needToInitialize = !mImpl;
Impl* newImpl = static_cast<Impl*>(PR_Realloc(mImpl, size * sizeof(void*)));
Impl* newImpl = static_cast<Impl*>(moz_realloc(mImpl, size * sizeof(void*)));
NS_ENSURE_TRUE(newImpl, false);
mImpl = newImpl;

View File

@ -6136,7 +6136,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
jsval& aBlob)
{
uint32_t blobLen = aData.Length();
void* blobData = PR_Malloc(blobLen);
void* blobData = moz_malloc(blobLen);
nsCOMPtr<nsIDOMBlob> blob;
if (blobData) {
memcpy(blobData, aData.BeginReading(), blobLen);

View File

@ -132,8 +132,7 @@ protected:
if (!bufferLen.isValid())
return false;
// PR_ memory functions are still fallible
void* data = PR_Realloc(mData, bufferLen.value());
void* data = moz_realloc(mData, bufferLen.value());
if (!data)
return false;

View File

@ -36,8 +36,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/Attributes.h"
#include "plbase64.h"
#include "prmem.h"
#include "mozilla/dom/FileListBinding.h"
using namespace mozilla;

View File

@ -20,9 +20,6 @@
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "plbase64.h"
#include "prmem.h"
#include "nsLayoutCID.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
@ -39,6 +36,7 @@
#include "nsLayoutStatics.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsHostObjectProtocolHandler.h"
#include "mozilla/Base64.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/EncodingUtils.h"
#include "xpcpublic.h"
@ -319,7 +317,7 @@ nsDOMFileReader::DoOnDataAvailable(nsIRequest *aRequest,
// PR_Realloc doesn't support over 4GB memory size even if 64-bit OS
return NS_ERROR_OUT_OF_MEMORY;
}
mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount);
mFileData = (char *)moz_realloc(mFileData, aOffset + aCount);
NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
uint32_t bytesRead = 0;
@ -491,26 +489,11 @@ nsDOMFileReader::GetAsDataURL(nsIDOMBlob *aFile,
}
aResult.AppendLiteral(";base64,");
uint32_t totalRead = 0;
while (aDataLen > totalRead) {
uint32_t numEncode = 4096;
uint32_t amtRemaining = aDataLen - totalRead;
if (numEncode > amtRemaining)
numEncode = amtRemaining;
nsCString encodedData;
rv = Base64Encode(Substring(aFileData, aDataLen), encodedData);
NS_ENSURE_SUCCESS(rv, rv);
//Unless this is the end of the file, encode in multiples of 3
if (numEncode > 3) {
uint32_t leftOver = numEncode % 3;
numEncode -= leftOver;
}
//Out buffer should be at least 4/3rds the read buf, plus a terminator
char *base64 = PL_Base64Encode(aFileData + totalRead, numEncode, nullptr);
AppendASCIItoUTF16(nsDependentCString(base64), aResult);
PR_Free(base64);
totalRead += numEncode;
}
AppendASCIItoUTF16(encodedData, aResult);
return NS_OK;
}

View File

@ -24,7 +24,6 @@
#include "nsCOMPtr.h"
#include "nsIStreamLoader.h"
#include "nsIChannel.h"
#include "prmem.h"
#include "FileIOObject.h"
@ -81,7 +80,7 @@ protected:
nsresult ConvertStream(const char *aFileData, uint32_t aDataLen, const char *aCharset, nsAString &aResult);
void FreeFileData() {
PR_Free(mFileData);
moz_free(mFileData);
mFileData = nullptr;
mDataLen = 0;
}