Backed out changeset 8c95cee5cd9e (bug 801466) because of test failures in mochitest-1

This commit is contained in:
Ehsan Akhgari 2012-12-06 01:09:30 -05:00
parent 4970895402
commit b04c552fdc
8 changed files with 38 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,6 +36,8 @@
#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,6 +20,9 @@
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "plbase64.h"
#include "prmem.h"
#include "nsLayoutCID.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
@ -36,7 +39,6 @@
#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"
@ -317,7 +319,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 *)moz_realloc(mFileData, aOffset + aCount);
mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount);
NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
uint32_t bytesRead = 0;
@ -489,11 +491,26 @@ nsDOMFileReader::GetAsDataURL(nsIDOMBlob *aFile,
}
aResult.AppendLiteral(";base64,");
nsCString encodedData;
rv = Base64Encode(Substring(aFileData, aDataLen), encodedData);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t totalRead = 0;
while (aDataLen > totalRead) {
uint32_t numEncode = 4096;
uint32_t amtRemaining = aDataLen - totalRead;
if (numEncode > amtRemaining)
numEncode = amtRemaining;
AppendASCIItoUTF16(encodedData, aResult);
//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;
}
return NS_OK;
}

View File

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