mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1138293 - Use malloc/free/realloc/calloc instead of moz_malloc/moz_free/moz_realloc/moz_calloc. r=njn
The distinction between moz_malloc/moz_free and malloc/free is not interesting. We are inconsistent in our use of one or the other, and I wouldn't be surprised if we are mixing them anyways.
This commit is contained in:
parent
39830fa50a
commit
95e047925a
@ -20,7 +20,7 @@ public:
|
|||||||
|
|
||||||
~BlobSet()
|
~BlobSet()
|
||||||
{
|
{
|
||||||
moz_free(mData);
|
free(mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
|
nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
|
||||||
@ -52,7 +52,7 @@ protected:
|
|||||||
if (!bufferLen.isValid())
|
if (!bufferLen.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
void* data = moz_realloc(mData, bufferLen.value());
|
void* data = realloc(mData, bufferLen.value());
|
||||||
if (!data)
|
if (!data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
uint64_t aLength);
|
uint64_t aLength);
|
||||||
|
|
||||||
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
|
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
|
||||||
// freed by moz_free so it must be allocated by moz_malloc or something
|
// freed by free so it must be allocated by malloc or something
|
||||||
// compatible with it.
|
// compatible with it.
|
||||||
static already_AddRefed<File>
|
static already_AddRefed<File>
|
||||||
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
|
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
uint64_t aLastModifiedDate);
|
uint64_t aLastModifiedDate);
|
||||||
|
|
||||||
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
|
// The returned File takes ownership of aMemoryBuffer. aMemoryBuffer will be
|
||||||
// freed by moz_free so it must be allocated by moz_malloc or something
|
// freed by free so it must be allocated by malloc or something
|
||||||
// compatible with it.
|
// compatible with it.
|
||||||
static already_AddRefed<File>
|
static already_AddRefed<File>
|
||||||
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
|
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
|
||||||
@ -552,7 +552,7 @@ public:
|
|||||||
sDataOwners = nullptr;
|
sDataOwners = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
moz_free(mData);
|
free(mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -102,7 +102,7 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
|
|||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
moz_free(mImpl);
|
free(mImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIContent*
|
nsIContent*
|
||||||
@ -635,11 +635,11 @@ nsAttrAndChildArray::Compact()
|
|||||||
// Then resize or free buffer
|
// Then resize or free buffer
|
||||||
uint32_t newSize = attrCount * ATTRSIZE + childCount;
|
uint32_t newSize = attrCount * ATTRSIZE + childCount;
|
||||||
if (!newSize && !mImpl->mMappedAttrs) {
|
if (!newSize && !mImpl->mMappedAttrs) {
|
||||||
moz_free(mImpl);
|
free(mImpl);
|
||||||
mImpl = nullptr;
|
mImpl = nullptr;
|
||||||
}
|
}
|
||||||
else if (newSize < mImpl->mBufferSize) {
|
else if (newSize < mImpl->mBufferSize) {
|
||||||
mImpl = static_cast<Impl*>(moz_realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
|
mImpl = static_cast<Impl*>(realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
|
||||||
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
|
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
|
||||||
|
|
||||||
mImpl->mBufferSize = newSize;
|
mImpl->mBufferSize = newSize;
|
||||||
@ -776,7 +776,7 @@ nsAttrAndChildArray::GrowBy(uint32_t aGrowSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool needToInitialize = !mImpl;
|
bool needToInitialize = !mImpl;
|
||||||
Impl* newImpl = static_cast<Impl*>(moz_realloc(mImpl, size * sizeof(void*)));
|
Impl* newImpl = static_cast<Impl*>(realloc(mImpl, size * sizeof(void*)));
|
||||||
NS_ENSURE_TRUE(newImpl, false);
|
NS_ENSURE_TRUE(newImpl, false);
|
||||||
|
|
||||||
mImpl = newImpl;
|
mImpl = newImpl;
|
||||||
|
@ -6052,7 +6052,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
|
|||||||
JS::MutableHandle<JS::Value> aBlob)
|
JS::MutableHandle<JS::Value> aBlob)
|
||||||
{
|
{
|
||||||
uint32_t blobLen = aData.Length();
|
uint32_t blobLen = aData.Length();
|
||||||
void* blobData = moz_malloc(blobLen);
|
void* blobData = malloc(blobLen);
|
||||||
nsRefPtr<File> blob;
|
nsRefPtr<File> blob;
|
||||||
if (blobData) {
|
if (blobData) {
|
||||||
memcpy(blobData, aData.BeginReading(), blobLen);
|
memcpy(blobData, aData.BeginReading(), blobLen);
|
||||||
|
@ -363,7 +363,7 @@ nsDOMFileReader::DoReadData(nsIAsyncInputStream* aStream, uint64_t aCount)
|
|||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (mDataFormat != FILE_AS_ARRAYBUFFER) {
|
if (mDataFormat != FILE_AS_ARRAYBUFFER) {
|
||||||
mFileData = (char *) moz_realloc(mFileData, mDataLen + aCount);
|
mFileData = (char *) realloc(mFileData, mDataLen + aCount);
|
||||||
NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(mFileData, NS_ERROR_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ protected:
|
|||||||
nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, uint32_t aDataLen, nsAString &aResult);
|
nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, uint32_t aDataLen, nsAString &aResult);
|
||||||
|
|
||||||
void FreeFileData() {
|
void FreeFileData() {
|
||||||
moz_free(mFileData);
|
free(mFileData);
|
||||||
mFileData = nullptr;
|
mFileData = nullptr;
|
||||||
mDataLen = 0;
|
mDataLen = 0;
|
||||||
}
|
}
|
||||||
|
@ -1461,7 +1461,7 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||||||
}
|
}
|
||||||
rv = NS_OK;
|
rv = NS_OK;
|
||||||
} else {
|
} else {
|
||||||
moz_free(const_cast<uint8_t *>(aString));
|
free(const_cast<uint8_t *>(aString));
|
||||||
rv = NS_SUCCESS_ADOPTED_DATA;
|
rv = NS_SUCCESS_ADOPTED_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void
|
|||||||
nsTextFragment::ReleaseText()
|
nsTextFragment::ReleaseText()
|
||||||
{
|
{
|
||||||
if (mState.mLength && m1b && mState.mInHeap) {
|
if (mState.mLength && m1b && mState.mInHeap) {
|
||||||
moz_free(m2b); // m1b == m2b as far as moz_free is concerned
|
free(m2b); // m1b == m2b as far as free is concerned
|
||||||
}
|
}
|
||||||
|
|
||||||
m1b = nullptr;
|
m1b = nullptr;
|
||||||
@ -107,7 +107,7 @@ nsTextFragment::operator=(const nsTextFragment& aOther)
|
|||||||
size_t m2bSize = aOther.mState.mLength *
|
size_t m2bSize = aOther.mState.mLength *
|
||||||
(aOther.mState.mIs2b ? sizeof(char16_t) : sizeof(char));
|
(aOther.mState.mIs2b ? sizeof(char16_t) : sizeof(char));
|
||||||
|
|
||||||
m2b = static_cast<char16_t*>(moz_malloc(m2bSize));
|
m2b = static_cast<char16_t*>(malloc(m2bSize));
|
||||||
if (m2b) {
|
if (m2b) {
|
||||||
memcpy(m2b, aOther.m2b, m2bSize);
|
memcpy(m2b, aOther.m2b, m2bSize);
|
||||||
} else {
|
} else {
|
||||||
@ -255,7 +255,7 @@ nsTextFragment::SetTo(const char16_t* aBuffer, int32_t aLength, bool aUpdateBidi
|
|||||||
if (first16bit != -1) { // aBuffer contains no non-8bit character
|
if (first16bit != -1) { // aBuffer contains no non-8bit character
|
||||||
// Use ucs2 storage because we have to
|
// Use ucs2 storage because we have to
|
||||||
size_t m2bSize = aLength * sizeof(char16_t);
|
size_t m2bSize = aLength * sizeof(char16_t);
|
||||||
m2b = (char16_t *)moz_malloc(m2bSize);
|
m2b = (char16_t *)malloc(m2bSize);
|
||||||
if (!m2b) {
|
if (!m2b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ nsTextFragment::SetTo(const char16_t* aBuffer, int32_t aLength, bool aUpdateBidi
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Use 1 byte storage because we can
|
// Use 1 byte storage because we can
|
||||||
char* buff = (char *)moz_malloc(aLength * sizeof(char));
|
char* buff = (char *)malloc(aLength * sizeof(char));
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
|
|||||||
|
|
||||||
if (mState.mIs2b) {
|
if (mState.mIs2b) {
|
||||||
// Already a 2-byte string so the result will be too
|
// Already a 2-byte string so the result will be too
|
||||||
char16_t* buff = (char16_t*)moz_realloc(m2b, (mState.mLength + aLength) * sizeof(char16_t));
|
char16_t* buff = (char16_t*)realloc(m2b, (mState.mLength + aLength) * sizeof(char16_t));
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -348,8 +348,8 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
|
|||||||
if (first16bit != -1) { // aBuffer contains no non-8bit character
|
if (first16bit != -1) { // aBuffer contains no non-8bit character
|
||||||
// The old data was 1-byte, but the new is not so we have to expand it
|
// The old data was 1-byte, but the new is not so we have to expand it
|
||||||
// all to 2-byte
|
// all to 2-byte
|
||||||
char16_t* buff = (char16_t*)moz_malloc((mState.mLength + aLength) *
|
char16_t* buff =
|
||||||
sizeof(char16_t));
|
(char16_t*)malloc((mState.mLength + aLength) * sizeof(char16_t));
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
|
|||||||
mState.mIs2b = true;
|
mState.mIs2b = true;
|
||||||
|
|
||||||
if (mState.mInHeap) {
|
if (mState.mInHeap) {
|
||||||
moz_free(m2b);
|
free(m2b);
|
||||||
}
|
}
|
||||||
m2b = buff;
|
m2b = buff;
|
||||||
|
|
||||||
@ -379,14 +379,14 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
|
|||||||
// The new and the old data is all 1-byte
|
// The new and the old data is all 1-byte
|
||||||
char* buff;
|
char* buff;
|
||||||
if (mState.mInHeap) {
|
if (mState.mInHeap) {
|
||||||
buff = (char*)moz_realloc(const_cast<char*>(m1b),
|
buff = (char*)realloc(const_cast<char*>(m1b),
|
||||||
(mState.mLength + aLength) * sizeof(char));
|
(mState.mLength + aLength) * sizeof(char));
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buff = (char*)moz_malloc((mState.mLength + aLength) * sizeof(char));
|
buff = (char*)malloc((mState.mLength + aLength) * sizeof(char));
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
|
|||||||
if (!boundBuffer)
|
if (!boundBuffer)
|
||||||
return ErrorInvalidOperation("bufferData: no buffer bound!");
|
return ErrorInvalidOperation("bufferData: no buffer bound!");
|
||||||
|
|
||||||
UniquePtr<uint8_t> zeroBuffer((uint8_t*)moz_calloc(size, 1));
|
UniquePtr<uint8_t> zeroBuffer((uint8_t*)calloc(size, 1));
|
||||||
if (!zeroBuffer)
|
if (!zeroBuffer)
|
||||||
return ErrorOutOfMemory("bufferData: out of memory");
|
return ErrorOutOfMemory("bufferData: out of memory");
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ public:
|
|||||||
|
|
||||||
~AutoFreeBuffer()
|
~AutoFreeBuffer()
|
||||||
{
|
{
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -14785,14 +14785,14 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
|
|||||||
reinterpret_cast<const char*>(mParams.cloneInfo().data().Elements());
|
reinterpret_cast<const char*>(mParams.cloneInfo().data().Elements());
|
||||||
size_t uncompressedLength = mParams.cloneInfo().data().Length();
|
size_t uncompressedLength = mParams.cloneInfo().data().Length();
|
||||||
|
|
||||||
// We don't have a smart pointer class that calls moz_free, so we need to
|
// We don't have a smart pointer class that calls free, so we need to
|
||||||
// manage | compressed | manually.
|
// manage | compressed | manually.
|
||||||
{
|
{
|
||||||
size_t compressedLength = snappy::MaxCompressedLength(uncompressedLength);
|
size_t compressedLength = snappy::MaxCompressedLength(uncompressedLength);
|
||||||
|
|
||||||
// moz_malloc is equivalent to NS_Alloc, which we use because mozStorage
|
// malloc is equivalent to NS_Alloc, which we use because mozStorage
|
||||||
// expects to be able to free the adopted pointer with NS_Free.
|
// expects to be able to free the adopted pointer with NS_Free.
|
||||||
char* compressed = static_cast<char*>(moz_malloc(compressedLength));
|
char* compressed = static_cast<char*>(malloc(compressedLength));
|
||||||
if (NS_WARN_IF(!compressed)) {
|
if (NS_WARN_IF(!compressed)) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -14808,7 +14808,7 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
|
|||||||
rv = stmt->BindAdoptedBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
|
rv = stmt->BindAdoptedBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
|
||||||
dataBufferLength);
|
dataBufferLength);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
moz_free(compressed);
|
free(compressed);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -836,7 +836,7 @@ CreateBlobImpl(const nsTArray<uint8_t>& aMemoryData,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buffer = moz_malloc(length * elementSizeMultiplier);
|
void* buffer = malloc(length * elementSizeMultiplier);
|
||||||
if (NS_WARN_IF(!buffer)) {
|
if (NS_WARN_IF(!buffer)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ EncodedBufferCache::ExtractBlob(nsISupports* aParent,
|
|||||||
mDataSize = 0;
|
mDataSize = 0;
|
||||||
mFD = nullptr;
|
mFD = nullptr;
|
||||||
} else {
|
} else {
|
||||||
void* blobData = moz_malloc(mDataSize);
|
void* blobData = malloc(mDataSize);
|
||||||
NS_ASSERTION(blobData, "out of memory!!");
|
NS_ASSERTION(blobData, "out of memory!!");
|
||||||
|
|
||||||
if (blobData) {
|
if (blobData) {
|
||||||
|
@ -255,7 +255,7 @@ AnalyserNode::FFTAnalysis()
|
|||||||
if (mWriteIndex == 0) {
|
if (mWriteIndex == 0) {
|
||||||
inputBuffer = mBuffer.Elements();
|
inputBuffer = mBuffer.Elements();
|
||||||
} else {
|
} else {
|
||||||
inputBuffer = static_cast<float*>(moz_malloc(FftSize() * sizeof(float)));
|
inputBuffer = static_cast<float*>(malloc(FftSize() * sizeof(float)));
|
||||||
if (!inputBuffer) {
|
if (!inputBuffer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ AnalyserNode::FFTAnalysis()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allocated) {
|
if (allocated) {
|
||||||
moz_free(inputBuffer);
|
free(inputBuffer);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ private:
|
|||||||
uint32_t mChunkSize;
|
uint32_t mChunkSize;
|
||||||
|
|
||||||
// chunking to 10ms support
|
// chunking to 10ms support
|
||||||
FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use moz_free()
|
FarEndAudioChunk *mSaved; // can't be nsAutoPtr since we need to use free(), not delete
|
||||||
uint32_t mSamplesSaved;
|
uint32_t mSamplesSaved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ MediaEngineGonkVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLeng
|
|||||||
: mPhotoDataLength(aLength)
|
: mPhotoDataLength(aLength)
|
||||||
{
|
{
|
||||||
mCallbacks.SwapElements(aCallbacks);
|
mCallbacks.SwapElements(aCallbacks);
|
||||||
mPhotoData = (uint8_t*) moz_malloc(aLength);
|
mPhotoData = (uint8_t*) malloc(aLength);
|
||||||
memcpy(mPhotoData, aData, mPhotoDataLength);
|
memcpy(mPhotoData, aData, mPhotoDataLength);
|
||||||
mMimeType = aMimeType;
|
mMimeType = aMimeType;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ AudioOutputObserver::AudioOutputObserver()
|
|||||||
AudioOutputObserver::~AudioOutputObserver()
|
AudioOutputObserver::~AudioOutputObserver()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
moz_free(mSaved);
|
free(mSaved);
|
||||||
mSaved = nullptr;
|
mSaved = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ void
|
|||||||
AudioOutputObserver::Clear()
|
AudioOutputObserver::Clear()
|
||||||
{
|
{
|
||||||
while (mPlayoutFifo->size() > 0) {
|
while (mPlayoutFifo->size() > 0) {
|
||||||
moz_free(mPlayoutFifo->Pop());
|
free(mPlayoutFifo->Pop());
|
||||||
}
|
}
|
||||||
// we'd like to touch mSaved here, but we can't if we might still be getting callbacks
|
// we'd like to touch mSaved here, but we can't if we might still be getting callbacks
|
||||||
}
|
}
|
||||||
@ -544,7 +544,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
|
|||||||
if (!mStarted) {
|
if (!mStarted) {
|
||||||
mStarted = true;
|
mStarted = true;
|
||||||
while (gFarendObserver->Size() > 1) {
|
while (gFarendObserver->Size() > 1) {
|
||||||
moz_free(gFarendObserver->Pop()); // only call if size() > 0
|
free(gFarendObserver->Pop()); // only call if size() > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
|
|||||||
gFarendObserver->PlayoutChannels(),
|
gFarendObserver->PlayoutChannels(),
|
||||||
mPlayoutDelay,
|
mPlayoutDelay,
|
||||||
length);
|
length);
|
||||||
moz_free(buffer);
|
free(buffer);
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -265,13 +265,13 @@ NSCursorInfo::NSCursorInfo(const Cursor* aCursor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
moz_free(bitmap);
|
free(bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSCursorInfo::~NSCursorInfo()
|
NSCursorInfo::~NSCursorInfo()
|
||||||
{
|
{
|
||||||
if (mCustomImageData) {
|
if (mCustomImageData) {
|
||||||
moz_free(mCustomImageData);
|
free(mCustomImageData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ NSCursor* NSCursorInfo::GetTransparentCursor() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
moz_free(data);
|
free(data);
|
||||||
|
|
||||||
// Fall back to an arrow cursor if (for some reason) the above code failed.
|
// Fall back to an arrow cursor if (for some reason) the above code failed.
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
@ -528,7 +528,7 @@ void NSCursorInfo::SetHotSpot(nsPoint aHotSpot)
|
|||||||
void NSCursorInfo::SetCustomImageData(uint8_t* aData, uint32_t aDataLength)
|
void NSCursorInfo::SetCustomImageData(uint8_t* aData, uint32_t aDataLength)
|
||||||
{
|
{
|
||||||
if (mCustomImageData) {
|
if (mCustomImageData) {
|
||||||
moz_free(mCustomImageData);
|
free(mCustomImageData);
|
||||||
}
|
}
|
||||||
if (aDataLength) {
|
if (aDataLength) {
|
||||||
mCustomImageData = (uint8_t*) moz_xmalloc(aDataLength);
|
mCustomImageData = (uint8_t*) moz_xmalloc(aDataLength);
|
||||||
|
@ -184,7 +184,7 @@ XULContentSinkImpl::~XULContentSinkImpl()
|
|||||||
NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
|
NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
|
||||||
mContextStack.Clear();
|
mContextStack.Clear();
|
||||||
|
|
||||||
moz_free(mText);
|
free(mText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@ -1051,7 +1051,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
|
|||||||
{
|
{
|
||||||
// Create buffer when we first need it
|
// Create buffer when we first need it
|
||||||
if (0 == mTextSize) {
|
if (0 == mTextSize) {
|
||||||
mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096);
|
mText = (char16_t *) malloc(sizeof(char16_t) * 4096);
|
||||||
if (nullptr == mText) {
|
if (nullptr == mText) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -1074,7 +1074,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTextSize += aLength;
|
mTextSize += aLength;
|
||||||
mText = (char16_t *) moz_realloc(mText, sizeof(char16_t) * mTextSize);
|
mText = (char16_t *) realloc(mText, sizeof(char16_t) * mTextSize);
|
||||||
if (nullptr == mText) {
|
if (nullptr == mText) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -134,14 +134,14 @@ struct AlignedArray
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
moz_free(mStorage);
|
free(mStorage);
|
||||||
mStorage = nullptr;
|
mStorage = nullptr;
|
||||||
mPtr = nullptr;
|
mPtr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE void Realloc(size_t aCount, bool aZero = false)
|
MOZ_ALWAYS_INLINE void Realloc(size_t aCount, bool aZero = false)
|
||||||
{
|
{
|
||||||
moz_free(mStorage);
|
free(mStorage);
|
||||||
CheckedInt32 storageByteCount =
|
CheckedInt32 storageByteCount =
|
||||||
CheckedInt32(sizeof(T)) * aCount + (alignment - 1);
|
CheckedInt32(sizeof(T)) * aCount + (alignment - 1);
|
||||||
if (!storageByteCount.isValid()) {
|
if (!storageByteCount.isValid()) {
|
||||||
@ -155,9 +155,9 @@ struct AlignedArray
|
|||||||
if (aZero) {
|
if (aZero) {
|
||||||
// calloc can be more efficient than new[] for large chunks,
|
// calloc can be more efficient than new[] for large chunks,
|
||||||
// so we use calloc/malloc/free for everything.
|
// so we use calloc/malloc/free for everything.
|
||||||
mStorage = static_cast<uint8_t *>(moz_calloc(1, storageByteCount.value()));
|
mStorage = static_cast<uint8_t *>(calloc(1, storageByteCount.value()));
|
||||||
} else {
|
} else {
|
||||||
mStorage = static_cast<uint8_t *>(moz_malloc(storageByteCount.value()));
|
mStorage = static_cast<uint8_t *>(malloc(storageByteCount.value()));
|
||||||
}
|
}
|
||||||
if (!mStorage) {
|
if (!mStorage) {
|
||||||
mStorage = nullptr;
|
mStorage = nullptr;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#ifndef MOZ_GR_MALLOC_H
|
#ifndef MOZ_GR_MALLOC_H
|
||||||
#define MOZ_GR_MALLOC_H
|
#define MOZ_GR_MALLOC_H
|
||||||
|
|
||||||
// Override malloc() and friends to call moz_malloc() etc, so that we get
|
// Override malloc() and friends to call moz_xmalloc() etc, so that we get
|
||||||
// predictable, safe OOM crashes rather than relying on the code to handle
|
// predictable, safe OOM crashes rather than relying on the code to handle
|
||||||
// allocation failures reliably.
|
// allocation failures reliably.
|
||||||
|
|
||||||
@ -15,6 +15,5 @@
|
|||||||
#define malloc moz_xmalloc
|
#define malloc moz_xmalloc
|
||||||
#define calloc moz_xcalloc
|
#define calloc moz_xcalloc
|
||||||
#define realloc moz_xrealloc
|
#define realloc moz_xrealloc
|
||||||
#define free moz_free
|
|
||||||
|
|
||||||
#endif // MOZ_GR_MALLOC_H
|
#endif // MOZ_GR_MALLOC_H
|
||||||
|
@ -64,10 +64,10 @@ index 0000000..1f16ee5
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void sk_free(void* p) {
|
+void sk_free(void* p) {
|
||||||
+ moz_free(p);
|
+ free(p);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void* sk_malloc_flags(size_t size, unsigned flags) {
|
+void* sk_malloc_flags(size_t size, unsigned flags) {
|
||||||
+ return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : moz_malloc(size);
|
+ return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : malloc(size);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
@ -31,15 +31,15 @@ void* sk_realloc_throw(void* addr, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sk_free(void* p) {
|
void sk_free(void* p) {
|
||||||
moz_free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* sk_malloc_flags(size_t size, unsigned flags) {
|
void* sk_malloc_flags(size_t size, unsigned flags) {
|
||||||
return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : moz_malloc(size);
|
return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* sk_calloc(size_t size) {
|
void* sk_calloc(size_t size) {
|
||||||
return moz_calloc(size, 1);
|
return calloc(size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* sk_calloc_throw(size_t size) {
|
void* sk_calloc_throw(size_t size) {
|
||||||
|
@ -107,7 +107,7 @@ public:
|
|||||||
NS_ASSERTION(item, "failed to find zip entry");
|
NS_ASSERTION(item, "failed to find zip entry");
|
||||||
|
|
||||||
uint32_t bufSize = item->RealSize();
|
uint32_t bufSize = item->RealSize();
|
||||||
mFontDataBuf = static_cast<uint8_t*>(moz_malloc(bufSize));
|
mFontDataBuf = static_cast<uint8_t*>(malloc(bufSize));
|
||||||
if (mFontDataBuf) {
|
if (mFontDataBuf) {
|
||||||
nsZipCursor cursor(item, reader, mFontDataBuf, bufSize);
|
nsZipCursor cursor(item, reader, mFontDataBuf, bufSize);
|
||||||
cursor.Copy(&bufSize);
|
cursor.Copy(&bufSize);
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
if (mFace && mOwnsFace) {
|
if (mFace && mOwnsFace) {
|
||||||
FT_Done_Face(mFace);
|
FT_Done_Face(mFace);
|
||||||
if (mFontDataBuf) {
|
if (mFontDataBuf) {
|
||||||
moz_free(mFontDataBuf);
|
free(mFontDataBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1152,7 @@ public:
|
|||||||
uint32_t size =
|
uint32_t size =
|
||||||
offsetof(gfxShapedWord, mCharGlyphsStorage) +
|
offsetof(gfxShapedWord, mCharGlyphsStorage) +
|
||||||
aLength * (sizeof(CompressedGlyph) + sizeof(uint8_t));
|
aLength * (sizeof(CompressedGlyph) + sizeof(uint8_t));
|
||||||
void *storage = moz_malloc(size);
|
void *storage = malloc(size);
|
||||||
if (!storage) {
|
if (!storage) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1183,7 +1183,7 @@ public:
|
|||||||
uint32_t size =
|
uint32_t size =
|
||||||
offsetof(gfxShapedWord, mCharGlyphsStorage) +
|
offsetof(gfxShapedWord, mCharGlyphsStorage) +
|
||||||
aLength * (sizeof(CompressedGlyph) + sizeof(char16_t));
|
aLength * (sizeof(CompressedGlyph) + sizeof(char16_t));
|
||||||
void *storage = moz_malloc(size);
|
void *storage = malloc(size);
|
||||||
if (!storage) {
|
if (!storage) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1193,9 +1193,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override operator delete to properly free the object that was
|
// Override operator delete to properly free the object that was
|
||||||
// allocated via moz_malloc.
|
// allocated via malloc.
|
||||||
void operator delete(void* p) {
|
void operator delete(void* p) {
|
||||||
moz_free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual CompressedGlyph *GetCharacterGlyphs() override {
|
virtual CompressedGlyph *GetCharacterGlyphs() override {
|
||||||
|
@ -95,7 +95,7 @@ TryAllocAlignedBytes(size_t aSize)
|
|||||||
nullptr : ptr;
|
nullptr : ptr;
|
||||||
#else
|
#else
|
||||||
// Oh well, hope that luck is with us in the allocator
|
// Oh well, hope that luck is with us in the allocator
|
||||||
return moz_malloc(aSize);
|
return malloc(aSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ gfxTextRun::AllocateStorageForTextRun(size_t aSize, uint32_t aLength)
|
|||||||
{
|
{
|
||||||
// Allocate the storage we need, returning nullptr on failure rather than
|
// Allocate the storage we need, returning nullptr on failure rather than
|
||||||
// throwing an exception (because web content can create huge runs).
|
// throwing an exception (because web content can create huge runs).
|
||||||
void *storage = moz_malloc(aSize + aLength * sizeof(CompressedGlyph));
|
void *storage = malloc(aSize + aLength * sizeof(CompressedGlyph));
|
||||||
if (!storage) {
|
if (!storage) {
|
||||||
NS_WARNING("failed to allocate storage for text run!");
|
NS_WARNING("failed to allocate storage for text run!");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -82,9 +82,9 @@ class gfxTextRun : public gfxShapedText {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// Override operator delete to properly free the object that was
|
// Override operator delete to properly free the object that was
|
||||||
// allocated via moz_malloc.
|
// allocated via malloc.
|
||||||
void operator delete(void* p) {
|
void operator delete(void* p) {
|
||||||
moz_free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~gfxTextRun();
|
virtual ~gfxTextRun();
|
||||||
|
@ -675,7 +675,7 @@ gfxUserFontEntry::LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength)
|
|||||||
|
|
||||||
// The downloaded data can now be discarded; the font entry is using the
|
// The downloaded data can now be discarded; the font entry is using the
|
||||||
// sanitized copy
|
// sanitized copy
|
||||||
moz_free((void*)aFontData);
|
free((void*)aFontData);
|
||||||
|
|
||||||
return fe != nullptr;
|
return fe != nullptr;
|
||||||
}
|
}
|
||||||
@ -690,7 +690,7 @@ gfxUserFontEntry::Load()
|
|||||||
|
|
||||||
// This is called when a font download finishes.
|
// This is called when a font download finishes.
|
||||||
// Ownership of aFontData passes in here, and the font set must
|
// Ownership of aFontData passes in here, and the font set must
|
||||||
// ensure that it is eventually deleted via moz_free().
|
// ensure that it is eventually deleted via free().
|
||||||
bool
|
bool
|
||||||
gfxUserFontEntry::FontDataDownloadComplete(const uint8_t* aFontData,
|
gfxUserFontEntry::FontDataDownloadComplete(const uint8_t* aFontData,
|
||||||
uint32_t aLength,
|
uint32_t aLength,
|
||||||
@ -718,7 +718,7 @@ gfxUserFontEntry::FontDataDownloadComplete(const uint8_t* aFontData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aFontData) {
|
if (aFontData) {
|
||||||
moz_free((void*)aFontData);
|
free((void*)aFontData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// error occurred, load next src
|
// error occurred, load next src
|
||||||
|
@ -60,7 +60,7 @@ nsBMPDecoder::~nsBMPDecoder()
|
|||||||
{
|
{
|
||||||
delete[] mColors;
|
delete[] mColors;
|
||||||
if (mRow) {
|
if (mRow) {
|
||||||
moz_free(mRow);
|
free(mRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
|||||||
if (mBIH.compression != BI_RLE8 && mBIH.compression != BI_RLE4 &&
|
if (mBIH.compression != BI_RLE8 && mBIH.compression != BI_RLE4 &&
|
||||||
mBIH.compression != BI_ALPHABITFIELDS) {
|
mBIH.compression != BI_ALPHABITFIELDS) {
|
||||||
// mRow is not used for RLE encoded images
|
// mRow is not used for RLE encoded images
|
||||||
mRow = (uint8_t*)moz_malloc((mBIH.width * mBIH.bpp) / 8 + 4);
|
mRow = (uint8_t*)malloc((mBIH.width * mBIH.bpp) / 8 + 4);
|
||||||
// + 4 because the line is padded to a 4 bit boundary, but
|
// + 4 because the line is padded to a 4 bit boundary, but
|
||||||
// I don't want to make exact calculations here, that's unnecessary.
|
// I don't want to make exact calculations here, that's unnecessary.
|
||||||
// Also, it compensates rounding error.
|
// Also, it compensates rounding error.
|
||||||
|
@ -93,8 +93,8 @@ nsGIFDecoder2::nsGIFDecoder2(RasterImage* aImage)
|
|||||||
|
|
||||||
nsGIFDecoder2::~nsGIFDecoder2()
|
nsGIFDecoder2::~nsGIFDecoder2()
|
||||||
{
|
{
|
||||||
moz_free(mGIFStruct.local_colormap);
|
free(mGIFStruct.local_colormap);
|
||||||
moz_free(mGIFStruct.hold);
|
free(mGIFStruct.hold);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1161,8 +1161,8 @@ nsGIFDecoder2::SetHold(const uint8_t* buf1, uint32_t count1,
|
|||||||
uint32_t count2 /* = 0 */)
|
uint32_t count2 /* = 0 */)
|
||||||
{
|
{
|
||||||
// We have to handle the case that buf currently points to hold
|
// We have to handle the case that buf currently points to hold
|
||||||
uint8_t* newHold = (uint8_t*) moz_malloc(std::max(uint32_t(MIN_HOLD_SIZE),
|
uint8_t* newHold = (uint8_t*) malloc(std::max(uint32_t(MIN_HOLD_SIZE),
|
||||||
count1 + count2));
|
count1 + count2));
|
||||||
if (!newHold) {
|
if (!newHold) {
|
||||||
mGIFStruct.state = gif_error;
|
mGIFStruct.state = gif_error;
|
||||||
return false;
|
return false;
|
||||||
@ -1173,7 +1173,7 @@ nsGIFDecoder2::SetHold(const uint8_t* buf1, uint32_t count1,
|
|||||||
memcpy(newHold + count1, buf2, count2);
|
memcpy(newHold + count1, buf2, count2);
|
||||||
}
|
}
|
||||||
|
|
||||||
moz_free(mGIFStruct.hold);
|
free(mGIFStruct.hold);
|
||||||
mGIFStruct.hold = newHold;
|
mGIFStruct.hold = newHold;
|
||||||
mGIFStruct.bytes_in_hold = count1 + count2;
|
mGIFStruct.bytes_in_hold = count1 + count2;
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,7 +70,7 @@ nsICODecoder::nsICODecoder(RasterImage* aImage)
|
|||||||
nsICODecoder::~nsICODecoder()
|
nsICODecoder::~nsICODecoder()
|
||||||
{
|
{
|
||||||
if (mRow) {
|
if (mRow) {
|
||||||
moz_free(mRow);
|
free(mRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
|||||||
mPos++;
|
mPos++;
|
||||||
mRowBytes = 0;
|
mRowBytes = 0;
|
||||||
mCurLine = GetRealHeight();
|
mCurLine = GetRealHeight();
|
||||||
mRow = (uint8_t*)moz_realloc(mRow, rowSize);
|
mRow = (uint8_t*)realloc(mRow, rowSize);
|
||||||
if (!mRow) {
|
if (!mRow) {
|
||||||
PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
|
PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
|
||||||
return;
|
return;
|
||||||
|
@ -661,7 +661,7 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
(channels <= 2 || interlace_type == PNG_INTERLACE_ADAM7)) {
|
(channels <= 2 || interlace_type == PNG_INTERLACE_ADAM7)) {
|
||||||
uint32_t bpp[] = { 0, 3, 4, 3, 4 };
|
uint32_t bpp[] = { 0, 3, 4, 3, 4 };
|
||||||
decoder->mCMSLine =
|
decoder->mCMSLine =
|
||||||
(uint8_t*)moz_malloc(bpp[channels] * width);
|
(uint8_t*)malloc(bpp[channels] * width);
|
||||||
if (!decoder->mCMSLine) {
|
if (!decoder->mCMSLine) {
|
||||||
png_longjmp(decoder->mPNG, 5); // NS_ERROR_OUT_OF_MEMORY
|
png_longjmp(decoder->mPNG, 5); // NS_ERROR_OUT_OF_MEMORY
|
||||||
}
|
}
|
||||||
@ -669,7 +669,7 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
if (interlace_type == PNG_INTERLACE_ADAM7) {
|
if (interlace_type == PNG_INTERLACE_ADAM7) {
|
||||||
if (height < INT32_MAX / (width * channels)) {
|
if (height < INT32_MAX / (width * channels)) {
|
||||||
decoder->interlacebuf = (uint8_t*)moz_malloc(channels * width * height);
|
decoder->interlacebuf = (uint8_t*)malloc(channels * width * height);
|
||||||
}
|
}
|
||||||
if (!decoder->interlacebuf) {
|
if (!decoder->interlacebuf) {
|
||||||
png_longjmp(decoder->mPNG, 5); // NS_ERROR_OUT_OF_MEMORY
|
png_longjmp(decoder->mPNG, 5); // NS_ERROR_OUT_OF_MEMORY
|
||||||
|
@ -30,7 +30,7 @@ nsBMPEncoder::nsBMPEncoder() : mImageBufferStart(nullptr),
|
|||||||
nsBMPEncoder::~nsBMPEncoder()
|
nsBMPEncoder::~nsBMPEncoder()
|
||||||
{
|
{
|
||||||
if (mImageBufferStart) {
|
if (mImageBufferStart) {
|
||||||
moz_free(mImageBufferStart);
|
free(mImageBufferStart);
|
||||||
mImageBufferStart = nullptr;
|
mImageBufferStart = nullptr;
|
||||||
mImageBufferCurr = nullptr;
|
mImageBufferCurr = nullptr;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ nsBMPEncoder::StartImageEncode(uint32_t aWidth,
|
|||||||
InitInfoHeader(version, bpp, aWidth, aHeight);
|
InitInfoHeader(version, bpp, aWidth, aHeight);
|
||||||
|
|
||||||
mImageBufferSize = mBMPFileHeader.filesize;
|
mImageBufferSize = mBMPFileHeader.filesize;
|
||||||
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
|
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
|
||||||
if (!mImageBufferStart) {
|
if (!mImageBufferStart) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ NS_IMETHODIMP
|
|||||||
nsBMPEncoder::Close()
|
nsBMPEncoder::Close()
|
||||||
{
|
{
|
||||||
if (mImageBufferStart) {
|
if (mImageBufferStart) {
|
||||||
moz_free(mImageBufferStart);
|
free(mImageBufferStart);
|
||||||
mImageBufferStart = nullptr;
|
mImageBufferStart = nullptr;
|
||||||
mImageBufferSize = 0;
|
mImageBufferSize = 0;
|
||||||
mImageBufferReadPoint = 0;
|
mImageBufferReadPoint = 0;
|
||||||
|
@ -31,7 +31,7 @@ nsICOEncoder::nsICOEncoder() : mImageBufferStart(nullptr),
|
|||||||
nsICOEncoder::~nsICOEncoder()
|
nsICOEncoder::~nsICOEncoder()
|
||||||
{
|
{
|
||||||
if (mImageBufferStart) {
|
if (mImageBufferStart) {
|
||||||
moz_free(mImageBufferStart);
|
free(mImageBufferStart);
|
||||||
mImageBufferStart = nullptr;
|
mImageBufferStart = nullptr;
|
||||||
mImageBufferCurr = nullptr;
|
mImageBufferCurr = nullptr;
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ nsICOEncoder::AddImageFrame(const uint8_t* aData,
|
|||||||
mContainedEncoder->GetImageBufferUsed(&PNGImageBufferSize);
|
mContainedEncoder->GetImageBufferUsed(&PNGImageBufferSize);
|
||||||
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
|
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
|
||||||
PNGImageBufferSize;
|
PNGImageBufferSize;
|
||||||
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
|
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
|
||||||
if (!mImageBufferStart) {
|
if (!mImageBufferStart) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ nsICOEncoder::AddImageFrame(const uint8_t* aData,
|
|||||||
mContainedEncoder->GetImageBufferUsed(&BMPImageBufferSize);
|
mContainedEncoder->GetImageBufferUsed(&BMPImageBufferSize);
|
||||||
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
|
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
|
||||||
BMPImageBufferSize + andMaskSize;
|
BMPImageBufferSize + andMaskSize;
|
||||||
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
|
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
|
||||||
if (!mImageBufferStart) {
|
if (!mImageBufferStart) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -334,7 +334,7 @@ NS_IMETHODIMP
|
|||||||
nsICOEncoder::Close()
|
nsICOEncoder::Close()
|
||||||
{
|
{
|
||||||
if (mImageBufferStart) {
|
if (mImageBufferStart) {
|
||||||
moz_free(mImageBufferStart);
|
free(mImageBufferStart);
|
||||||
mImageBufferStart = nullptr;
|
mImageBufferStart = nullptr;
|
||||||
mImageBufferSize = 0;
|
mImageBufferSize = 0;
|
||||||
mImageBufferReadPoint = 0;
|
mImageBufferReadPoint = 0;
|
||||||
|
@ -39,7 +39,7 @@ nsJPEGEncoder::nsJPEGEncoder()
|
|||||||
nsJPEGEncoder::~nsJPEGEncoder()
|
nsJPEGEncoder::~nsJPEGEncoder()
|
||||||
{
|
{
|
||||||
if (mImageBuffer) {
|
if (mImageBuffer) {
|
||||||
moz_free(mImageBuffer);
|
free(mImageBuffer);
|
||||||
mImageBuffer = nullptr;
|
mImageBuffer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ NS_IMETHODIMP
|
|||||||
nsJPEGEncoder::Close()
|
nsJPEGEncoder::Close()
|
||||||
{
|
{
|
||||||
if (mImageBuffer != nullptr) {
|
if (mImageBuffer != nullptr) {
|
||||||
moz_free(mImageBuffer);
|
free(mImageBuffer);
|
||||||
mImageBuffer = nullptr;
|
mImageBuffer = nullptr;
|
||||||
mImageBufferSize = 0;
|
mImageBufferSize = 0;
|
||||||
mImageBufferUsed = 0;
|
mImageBufferUsed = 0;
|
||||||
@ -404,7 +404,7 @@ nsJPEGEncoder::initDestination(jpeg_compress_struct* cinfo)
|
|||||||
NS_ASSERTION(!that->mImageBuffer, "Image buffer already initialized");
|
NS_ASSERTION(!that->mImageBuffer, "Image buffer already initialized");
|
||||||
|
|
||||||
that->mImageBufferSize = 8192;
|
that->mImageBufferSize = 8192;
|
||||||
that->mImageBuffer = (uint8_t*)moz_malloc(that->mImageBufferSize);
|
that->mImageBuffer = (uint8_t*)malloc(that->mImageBufferSize);
|
||||||
that->mImageBufferUsed = 0;
|
that->mImageBufferUsed = 0;
|
||||||
|
|
||||||
cinfo->dest->next_output_byte = that->mImageBuffer;
|
cinfo->dest->next_output_byte = that->mImageBuffer;
|
||||||
@ -438,11 +438,11 @@ nsJPEGEncoder::emptyOutputBuffer(jpeg_compress_struct* cinfo)
|
|||||||
// expand buffer, just double size each time
|
// expand buffer, just double size each time
|
||||||
that->mImageBufferSize *= 2;
|
that->mImageBufferSize *= 2;
|
||||||
|
|
||||||
uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
|
uint8_t* newBuf = (uint8_t*)realloc(that->mImageBuffer,
|
||||||
that->mImageBufferSize);
|
that->mImageBufferSize);
|
||||||
if (!newBuf) {
|
if (!newBuf) {
|
||||||
// can't resize, just zero (this will keep us from writing more)
|
// can't resize, just zero (this will keep us from writing more)
|
||||||
moz_free(that->mImageBuffer);
|
free(that->mImageBuffer);
|
||||||
that->mImageBuffer = nullptr;
|
that->mImageBuffer = nullptr;
|
||||||
that->mImageBufferSize = 0;
|
that->mImageBufferSize = 0;
|
||||||
that->mImageBufferUsed = 0;
|
that->mImageBufferUsed = 0;
|
||||||
|
@ -42,7 +42,7 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(nullptr), mPNGinfo(nullptr),
|
|||||||
nsPNGEncoder::~nsPNGEncoder()
|
nsPNGEncoder::~nsPNGEncoder()
|
||||||
{
|
{
|
||||||
if (mImageBuffer) {
|
if (mImageBuffer) {
|
||||||
moz_free(mImageBuffer);
|
free(mImageBuffer);
|
||||||
mImageBuffer = nullptr;
|
mImageBuffer = nullptr;
|
||||||
}
|
}
|
||||||
// don't leak if EndImageEncode wasn't called
|
// don't leak if EndImageEncode wasn't called
|
||||||
@ -155,7 +155,7 @@ nsPNGEncoder::StartImageEncode(uint32_t aWidth,
|
|||||||
// estimated size. Note: we don't have to worry about freeing this data
|
// estimated size. Note: we don't have to worry about freeing this data
|
||||||
// in this function. It will be freed on object destruction.
|
// in this function. It will be freed on object destruction.
|
||||||
mImageBufferSize = 8192;
|
mImageBufferSize = 8192;
|
||||||
mImageBuffer = (uint8_t*)moz_malloc(mImageBufferSize);
|
mImageBuffer = (uint8_t*)malloc(mImageBufferSize);
|
||||||
if (!mImageBuffer) {
|
if (!mImageBuffer) {
|
||||||
png_destroy_write_struct(&mPNG, &mPNGinfo);
|
png_destroy_write_struct(&mPNG, &mPNGinfo);
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
@ -532,7 +532,7 @@ NS_IMETHODIMP
|
|||||||
nsPNGEncoder::Close()
|
nsPNGEncoder::Close()
|
||||||
{
|
{
|
||||||
if (mImageBuffer != nullptr) {
|
if (mImageBuffer != nullptr) {
|
||||||
moz_free(mImageBuffer);
|
free(mImageBuffer);
|
||||||
mImageBuffer = nullptr;
|
mImageBuffer = nullptr;
|
||||||
mImageBufferSize = 0;
|
mImageBufferSize = 0;
|
||||||
mImageBufferUsed = 0;
|
mImageBufferUsed = 0;
|
||||||
@ -733,11 +733,11 @@ nsPNGEncoder::WriteCallback(png_structp png, png_bytep data,
|
|||||||
|
|
||||||
// expand buffer, just double each time
|
// expand buffer, just double each time
|
||||||
that->mImageBufferSize *= 2;
|
that->mImageBufferSize *= 2;
|
||||||
uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
|
uint8_t* newBuf = (uint8_t*)realloc(that->mImageBuffer,
|
||||||
that->mImageBufferSize);
|
that->mImageBufferSize);
|
||||||
if (!newBuf) {
|
if (!newBuf) {
|
||||||
// can't resize, just zero (this will keep us from writing more)
|
// can't resize, just zero (this will keep us from writing more)
|
||||||
moz_free(that->mImageBuffer);
|
free(that->mImageBuffer);
|
||||||
that->mImageBuffer = nullptr;
|
that->mImageBuffer = nullptr;
|
||||||
that->mImageBufferSize = 0;
|
that->mImageBufferSize = 0;
|
||||||
that->mImageBufferUsed = 0;
|
that->mImageBufferUsed = 0;
|
||||||
|
@ -161,7 +161,7 @@ imgFrame::~imgFrame()
|
|||||||
MOZ_ASSERT(mAborted || IsImageCompleteInternal());
|
MOZ_ASSERT(mAborted || IsImageCompleteInternal());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
moz_free(mPalettedImageData);
|
free(mPalettedImageData);
|
||||||
mPalettedImageData = nullptr;
|
mPalettedImageData = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ imgFrame::ReinitForDecoder(const nsIntSize& aImageSize,
|
|||||||
mOptSurface = nullptr;
|
mOptSurface = nullptr;
|
||||||
mVBuf = nullptr;
|
mVBuf = nullptr;
|
||||||
mVBufPtr = nullptr;
|
mVBufPtr = nullptr;
|
||||||
moz_free(mPalettedImageData);
|
free(mPalettedImageData);
|
||||||
mPalettedImageData = nullptr;
|
mPalettedImageData = nullptr;
|
||||||
|
|
||||||
// Reinitialize.
|
// Reinitialize.
|
||||||
@ -274,10 +274,10 @@ imgFrame::InitForDecoder(const nsIntSize& aImageSize,
|
|||||||
// Use the fallible allocator here. Paletted images always use 1 byte per
|
// Use the fallible allocator here. Paletted images always use 1 byte per
|
||||||
// pixel, so calculating the amount of memory we need is straightforward.
|
// pixel, so calculating the amount of memory we need is straightforward.
|
||||||
mPalettedImageData =
|
mPalettedImageData =
|
||||||
static_cast<uint8_t*>(moz_malloc(PaletteDataLength() +
|
static_cast<uint8_t*>(malloc(PaletteDataLength() +
|
||||||
(mSize.width * mSize.height)));
|
(mSize.width * mSize.height)));
|
||||||
if (!mPalettedImageData)
|
if (!mPalettedImageData)
|
||||||
NS_WARNING("moz_malloc for paletted image data should succeed");
|
NS_WARNING("malloc for paletted image data should succeed");
|
||||||
NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(mPalettedImageData, NS_ERROR_OUT_OF_MEMORY);
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitForDecoder() twice?");
|
MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitForDecoder() twice?");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define hnj_malloc(size) moz_xmalloc(size)
|
#define hnj_malloc(size) moz_xmalloc(size)
|
||||||
#define hnj_realloc(p, size) moz_xrealloc(p, size)
|
#define hnj_realloc(p, size) moz_xrealloc(p, size)
|
||||||
#define hnj_free(p) moz_free(p)
|
#define hnj_free(p) free(p)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To enable us to load hyphenation dictionaries from arbitrary resource URIs,
|
* To enable us to load hyphenation dictionaries from arbitrary resource URIs,
|
||||||
|
@ -40,12 +40,12 @@ nsCollationMacUC::~nsCollationMacUC()
|
|||||||
NS_ASSERTION(NS_SUCCEEDED(res), "CleanUpCollator failed");
|
NS_ASSERTION(NS_SUCCEEDED(res), "CleanUpCollator failed");
|
||||||
if (mUseICU) {
|
if (mUseICU) {
|
||||||
if (mLocaleICU) {
|
if (mLocaleICU) {
|
||||||
moz_free(mLocaleICU);
|
free(mLocaleICU);
|
||||||
mLocaleICU = nullptr;
|
mLocaleICU = nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mBuffer) {
|
if (mBuffer) {
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ nsresult nsCollationMacUC::ConvertLocaleICU(nsILocale* aNSLocale, char** aICULoc
|
|||||||
NS_ERROR_FAILURE);
|
NS_ERROR_FAILURE);
|
||||||
NS_LossyConvertUTF16toASCII tmp(localeString);
|
NS_LossyConvertUTF16toASCII tmp(localeString);
|
||||||
tmp.ReplaceChar('-', '_');
|
tmp.ReplaceChar('-', '_');
|
||||||
char* locale = (char*)moz_malloc(tmp.Length() + 1);
|
char* locale = (char*)malloc(tmp.Length() + 1);
|
||||||
if (!locale) {
|
if (!locale) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -273,13 +273,13 @@ NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsASt
|
|||||||
do {
|
do {
|
||||||
newBufferLen *= 2;
|
newBufferLen *= 2;
|
||||||
} while (newBufferLen < maxKeyLen);
|
} while (newBufferLen < maxKeyLen);
|
||||||
void* newBuffer = moz_malloc(newBufferLen);
|
void* newBuffer = malloc(newBufferLen);
|
||||||
if (!newBuffer) {
|
if (!newBuffer) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBuffer) {
|
if (mBuffer) {
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
}
|
}
|
||||||
mBuffer = newBuffer;
|
mBuffer = newBuffer;
|
||||||
|
@ -39,7 +39,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc
|
|||||||
const nsAFlatString& flatSrc = PromiseFlatString(aSrc);
|
const nsAFlatString& flatSrc = PromiseFlatString(aSrc);
|
||||||
rv = mEncoder->GetMaxLength(flatSrc.get(), inLength, aOutLen);
|
rv = mEncoder->GetMaxLength(flatSrc.get(), inLength, aOutLen);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
*_retval = (char*)moz_malloc(*aOutLen+1);
|
*_retval = (char*)malloc(*aOutLen+1);
|
||||||
if (!*_retval)
|
if (!*_retval)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc
|
|||||||
(*_retval)[*aOutLen] = '\0';
|
(*_retval)[*aOutLen] = '\0';
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
moz_free(*_retval);
|
free(*_retval);
|
||||||
}
|
}
|
||||||
*_retval = nullptr;
|
*_retval = nullptr;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@ -68,7 +68,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicode(const nsAString& aSrc,
|
|||||||
if (!_retval.Assign(str, len, mozilla::fallible)) {
|
if (!_retval.Assign(str, len, mozilla::fallible)) {
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
moz_free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ nsScriptableUnicodeConverter::FinishWithLength(char **_retval, int32_t* aLength)
|
|||||||
|
|
||||||
int32_t finLength = 32;
|
int32_t finLength = 32;
|
||||||
|
|
||||||
*_retval = (char *)moz_malloc(finLength);
|
*_retval = (char *)malloc(finLength);
|
||||||
if (!*_retval)
|
if (!*_retval)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ nsScriptableUnicodeConverter::FinishWithLength(char **_retval, int32_t* aLength)
|
|||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
*aLength = finLength;
|
*aLength = finLength;
|
||||||
else
|
else
|
||||||
moz_free(*_retval);
|
free(*_retval);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ nsScriptableUnicodeConverter::Finish(nsACString& _retval)
|
|||||||
if (!_retval.Assign(str, len, mozilla::fallible)) {
|
if (!_retval.Assign(str, len, mozilla::fallible)) {
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
moz_free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ nsScriptableUnicodeConverter::ConvertFromByteArray(const uint8_t* aData,
|
|||||||
inLength, &outLength);
|
inLength, &outLength);
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
char16_t* buf = (char16_t*)moz_malloc((outLength+1)*sizeof(char16_t));
|
char16_t* buf = (char16_t*)malloc((outLength+1) * sizeof(char16_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ nsScriptableUnicodeConverter::ConvertFromByteArray(const uint8_t* aData,
|
|||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
moz_free(buf);
|
free(buf);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@ -193,9 +193,9 @@ nsScriptableUnicodeConverter::ConvertToByteArray(const nsAString& aString,
|
|||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
str.Append(data, len);
|
str.Append(data, len);
|
||||||
moz_free(data);
|
free(data);
|
||||||
// NOTE: this being a byte array, it needs no null termination
|
// NOTE: this being a byte array, it needs no null termination
|
||||||
*_aData = reinterpret_cast<uint8_t*>(moz_malloc(str.Length()));
|
*_aData = reinterpret_cast<uint8_t*>(malloc(str.Length()));
|
||||||
if (!*_aData)
|
if (!*_aData)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
memcpy(*_aData, str.get(), str.Length());
|
memcpy(*_aData, str.get(), str.Length());
|
||||||
@ -222,7 +222,7 @@ nsScriptableUnicodeConverter::ConvertToInputStream(const nsAString& aString,
|
|||||||
|
|
||||||
rv = inputStream->AdoptData(reinterpret_cast<char*>(data), dataLen);
|
rv = inputStream->AdoptData(reinterpret_cast<char*>(data), dataLen);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
moz_free(data);
|
free(data);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
|
|||||||
reply->writeInt32(dataLength);
|
reply->writeInt32(dataLength);
|
||||||
void* buf = reply->writeInplace(dataLength);
|
void* buf = reply->writeInplace(dataLength);
|
||||||
memcpy(buf, data, dataLength);
|
memcpy(buf, data, dataLength);
|
||||||
moz_free(data);
|
free(data);
|
||||||
} else {
|
} else {
|
||||||
reply->writeInt32(-1);
|
reply->writeInt32(-1);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
|
|||||||
reply->writeInt32(dataLength);
|
reply->writeInt32(dataLength);
|
||||||
void* buf = reply->writeInplace(dataLength);
|
void* buf = reply->writeInplace(dataLength);
|
||||||
memcpy(buf, data, dataLength);
|
memcpy(buf, data, dataLength);
|
||||||
moz_free(data);
|
free(data);
|
||||||
} else {
|
} else {
|
||||||
reply->writeInt32(-1);
|
reply->writeInt32(-1);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
|
|||||||
reply->writeInt32(signResultSize);
|
reply->writeInt32(signResultSize);
|
||||||
void* buf = reply->writeInplace(signResultSize);
|
void* buf = reply->writeInplace(signResultSize);
|
||||||
memcpy(buf, signResult, signResultSize);
|
memcpy(buf, signResult, signResultSize);
|
||||||
moz_free(signResult);
|
free(signResult);
|
||||||
} else {
|
} else {
|
||||||
reply->writeInt32(-1);
|
reply->writeInt32(-1);
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ FormatCaData(const char *aCaData, int aCaDataLength,
|
|||||||
size_t bufSize = strlen(CA_BEGIN) + strlen(CA_END) + strlen(CA_TAILER) * 2 +
|
size_t bufSize = strlen(CA_BEGIN) + strlen(CA_END) + strlen(CA_TAILER) * 2 +
|
||||||
strlen(aName) * 2 + aCaDataLength + aCaDataLength/CA_LINE_SIZE
|
strlen(aName) * 2 + aCaDataLength + aCaDataLength/CA_LINE_SIZE
|
||||||
+ 2;
|
+ 2;
|
||||||
char *buf = (char *)moz_malloc(bufSize);
|
char *buf = (char *)malloc(bufSize);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
*aFormatData = nullptr;
|
*aFormatData = nullptr;
|
||||||
return;
|
return;
|
||||||
@ -571,7 +571,7 @@ ResponseCode getPublicKey(const char *aKeyName, const uint8_t **aKeyData,
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t bufSize = keyItem->len;
|
size_t bufSize = keyItem->len;
|
||||||
char *buf = (char *)moz_malloc(bufSize);
|
char *buf = (char *)malloc(bufSize);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return SYSTEM_ERROR;
|
return SYSTEM_ERROR;
|
||||||
}
|
}
|
||||||
@ -647,7 +647,7 @@ ResponseCode signData(const char *aKeyName, const uint8_t *data, size_t length,
|
|||||||
return SYSTEM_ERROR;
|
return SYSTEM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *buf = (uint8_t *)moz_malloc(signItem->len);
|
uint8_t *buf = (uint8_t *)malloc(signItem->len);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return SYSTEM_ERROR;
|
return SYSTEM_ERROR;
|
||||||
}
|
}
|
||||||
@ -1073,7 +1073,7 @@ KeyStore::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
|
|||||||
SendResponse(SUCCESS);
|
SendResponse(SUCCESS);
|
||||||
SendData(data, (int)dataLength);
|
SendData(data, (int)dataLength);
|
||||||
|
|
||||||
moz_free((void *)data);
|
free((void *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetHandlerInfo();
|
ResetHandlerInfo();
|
||||||
|
@ -190,7 +190,7 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
|
|||||||
if(!aMayAllocate) {
|
if(!aMayAllocate) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
*aMemory=moz_malloc(aSizeNeeded);
|
*aMemory=malloc(aSizeNeeded);
|
||||||
if (*aMemory!=nullptr) {
|
if (*aMemory!=nullptr) {
|
||||||
*aSize=aSizeNeeded;
|
*aSize=aSizeNeeded;
|
||||||
return true;
|
return true;
|
||||||
@ -206,7 +206,7 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
|
|||||||
return false;
|
return false;
|
||||||
} else if(aSizeNeeded!=*aSize && aMayAllocate) {
|
} else if(aSizeNeeded!=*aSize && aMayAllocate) {
|
||||||
/* we may try to grow or shrink */
|
/* we may try to grow or shrink */
|
||||||
void *memory=moz_realloc(*aMemory, aSizeNeeded);
|
void *memory=realloc(*aMemory, aSizeNeeded);
|
||||||
|
|
||||||
if(memory!=nullptr) {
|
if(memory!=nullptr) {
|
||||||
*aMemory=memory;
|
*aMemory=memory;
|
||||||
@ -225,11 +225,11 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
|
|||||||
|
|
||||||
void nsBidi::Free()
|
void nsBidi::Free()
|
||||||
{
|
{
|
||||||
moz_free(mDirPropsMemory);
|
free(mDirPropsMemory);
|
||||||
mDirPropsMemory = nullptr;
|
mDirPropsMemory = nullptr;
|
||||||
moz_free(mLevelsMemory);
|
free(mLevelsMemory);
|
||||||
mLevelsMemory = nullptr;
|
mLevelsMemory = nullptr;
|
||||||
moz_free(mRunsMemory);
|
free(mRunsMemory);
|
||||||
mRunsMemory = nullptr;
|
mRunsMemory = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ ComputeDescendantISize(const nsHTMLReflowState& aAncestorReflowState,
|
|||||||
for (uint32_t i = len; i-- != 0; ) {
|
for (uint32_t i = len; i-- != 0; ) {
|
||||||
reflowStates[i].~nsHTMLReflowState();
|
reflowStates[i].~nsHTMLReflowState();
|
||||||
}
|
}
|
||||||
moz_free(reflowStates);
|
free(reflowStates);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ GetDataFrom(const T& aObject, uint8_t*& aBuffer, uint32_t& aLength)
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(!aBuffer);
|
MOZ_ASSERT(!aBuffer);
|
||||||
aObject.ComputeLengthAndData();
|
aObject.ComputeLengthAndData();
|
||||||
// We use moz_malloc here rather than a FallibleTArray or fallible
|
// We use malloc here rather than a FallibleTArray or fallible
|
||||||
// operator new[] since the gfxUserFontEntry will be calling moz_free
|
// operator new[] since the gfxUserFontEntry will be calling free
|
||||||
// on it.
|
// on it.
|
||||||
aBuffer = (uint8_t*) moz_malloc(aObject.Length());
|
aBuffer = (uint8_t*) malloc(aObject.Length());
|
||||||
if (!aBuffer) {
|
if (!aBuffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ create_timecard()
|
|||||||
void
|
void
|
||||||
destroy_timecard(Timecard *tc)
|
destroy_timecard(Timecard *tc)
|
||||||
{
|
{
|
||||||
moz_free(tc->entries);
|
free(tc->entries);
|
||||||
moz_free(tc);
|
free(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#define cpr_malloc(a) moz_xmalloc(a)
|
#define cpr_malloc(a) moz_xmalloc(a)
|
||||||
#define cpr_calloc(a, b) moz_xcalloc(a, b)
|
#define cpr_calloc(a, b) moz_xcalloc(a, b)
|
||||||
#define cpr_realloc(a, b) moz_xrealloc(a, b)
|
#define cpr_realloc(a, b) moz_xrealloc(a, b)
|
||||||
#define cpr_free(a) moz_free(a)
|
#define cpr_free(a) free(a)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,8 +27,8 @@ interface nsIStreamLoaderObserver : nsISupports
|
|||||||
* If the observer wants to take over responsibility for the
|
* If the observer wants to take over responsibility for the
|
||||||
* data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
|
* data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
|
||||||
* in place of NS_OK as its success code. The loader will then
|
* in place of NS_OK as its success code. The loader will then
|
||||||
* "forget" about the data and not moz_free() it after
|
* "forget" about the data and not free() it after
|
||||||
* onStreamComplete() returns; observer must call moz_free()
|
* onStreamComplete() returns; observer must call free()
|
||||||
* when the data is no longer required.
|
* when the data is no longer required.
|
||||||
*/
|
*/
|
||||||
void onStreamComplete(in nsIStreamLoader loader,
|
void onStreamComplete(in nsIStreamLoader loader,
|
||||||
|
@ -28,7 +28,7 @@ nsPreloadedStream::nsPreloadedStream(nsIAsyncInputStream *aStream,
|
|||||||
|
|
||||||
nsPreloadedStream::~nsPreloadedStream()
|
nsPreloadedStream::~nsPreloadedStream()
|
||||||
{
|
{
|
||||||
moz_free(mBuf);
|
free(mBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -103,9 +103,9 @@ nsSocketTransportService::~nsSocketTransportService()
|
|||||||
if (mThreadEvent)
|
if (mThreadEvent)
|
||||||
PR_DestroyPollableEvent(mThreadEvent);
|
PR_DestroyPollableEvent(mThreadEvent);
|
||||||
|
|
||||||
moz_free(mActiveList);
|
free(mActiveList);
|
||||||
moz_free(mIdleList);
|
free(mIdleList);
|
||||||
moz_free(mPollList);
|
free(mPollList);
|
||||||
gSocketTransportService = nullptr;
|
gSocketTransportService = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
netwerk/cache/nsCacheMetaData.cpp
vendored
2
netwerk/cache/nsCacheMetaData.cpp
vendored
@ -151,7 +151,7 @@ nsresult
|
|||||||
nsCacheMetaData::EnsureBuffer(uint32_t bufSize)
|
nsCacheMetaData::EnsureBuffer(uint32_t bufSize)
|
||||||
{
|
{
|
||||||
if (mBufferSize < bufSize) {
|
if (mBufferSize < bufSize) {
|
||||||
char * buf = (char *)moz_realloc(mBuffer, bufSize);
|
char * buf = (char *)realloc(mBuffer, bufSize);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
2
netwerk/cache/nsCacheMetaData.h
vendored
2
netwerk/cache/nsCacheMetaData.h
vendored
@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
~nsCacheMetaData() {
|
~nsCacheMetaData() {
|
||||||
mBufferSize = mMetaSize = 0;
|
mBufferSize = mMetaSize = 0;
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
mBuffer = nullptr;
|
mBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ CacheFileChunk::Read(CacheFileHandle *aHandle, uint32_t aLen,
|
|||||||
mState = READING;
|
mState = READING;
|
||||||
|
|
||||||
if (CanAllocate(aLen)) {
|
if (CanAllocate(aLen)) {
|
||||||
mRWBuf = static_cast<char *>(moz_malloc(aLen));
|
mRWBuf = static_cast<char *>(malloc(aLen));
|
||||||
if (mRWBuf) {
|
if (mRWBuf) {
|
||||||
mRWBufSize = aLen;
|
mRWBufSize = aLen;
|
||||||
ChunkAllocationChanged();
|
ChunkAllocationChanged();
|
||||||
@ -698,7 +698,7 @@ CacheFileChunk::EnsureBufSize(uint32_t aBufSize)
|
|||||||
return mStatus;
|
return mStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *newBuf = static_cast<char *>(moz_realloc(mBuf, aBufSize));
|
char *newBuf = static_cast<char *>(realloc(mBuf, aBufSize));
|
||||||
if (!newBuf) {
|
if (!newBuf) {
|
||||||
SetError(NS_ERROR_OUT_OF_MEMORY);
|
SetError(NS_ERROR_OUT_OF_MEMORY);
|
||||||
return mStatus;
|
return mStatus;
|
||||||
|
@ -287,8 +287,8 @@ AddrInfo::~AddrInfo()
|
|||||||
while ((addrElement = mAddresses.popLast())) {
|
while ((addrElement = mAddresses.popLast())) {
|
||||||
delete addrElement;
|
delete addrElement;
|
||||||
}
|
}
|
||||||
moz_free(mHostName);
|
free(mHostName);
|
||||||
moz_free(mCanonicalName);
|
free(mCanonicalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -24,7 +24,7 @@ SpdyZlibReporter::Alloc(void*, uInt items, uInt size)
|
|||||||
SpdyZlibReporter::Free(void*, void* p)
|
SpdyZlibReporter::Free(void*, void* p)
|
||||||
{
|
{
|
||||||
sAmount -= MallocSizeOfOnFree(p);
|
sAmount -= MallocSizeOfOnFree(p);
|
||||||
moz_free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -1170,8 +1170,8 @@ WebSocketChannel::~WebSocketChannel()
|
|||||||
MOZ_ASSERT(!mCancelable, "DNS/Proxy Request still alive at destruction");
|
MOZ_ASSERT(!mCancelable, "DNS/Proxy Request still alive at destruction");
|
||||||
MOZ_ASSERT(!mConnecting, "Should not be connecting in destructor");
|
MOZ_ASSERT(!mConnecting, "Should not be connecting in destructor");
|
||||||
|
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
moz_free(mDynamicOutput);
|
free(mDynamicOutput);
|
||||||
delete mCurrentOut;
|
delete mCurrentOut;
|
||||||
|
|
||||||
while ((mCurrentOut = (OutboundMessage *) mOutgoingPingMessages.PopFront()))
|
while ((mCurrentOut = (OutboundMessage *) mOutgoingPingMessages.PopFront()))
|
||||||
@ -1400,7 +1400,7 @@ WebSocketChannel::UpdateReadBuffer(uint8_t *buffer, uint32_t count,
|
|||||||
mBufferSize += count + 8192 + mBufferSize/3;
|
mBufferSize += count + 8192 + mBufferSize/3;
|
||||||
LOG(("WebSocketChannel: update read buffer extended to %u\n", mBufferSize));
|
LOG(("WebSocketChannel: update read buffer extended to %u\n", mBufferSize));
|
||||||
uint8_t *old = mBuffer;
|
uint8_t *old = mBuffer;
|
||||||
mBuffer = (uint8_t *)moz_realloc(mBuffer, mBufferSize);
|
mBuffer = (uint8_t *)realloc(mBuffer, mBufferSize);
|
||||||
if (!mBuffer) {
|
if (!mBuffer) {
|
||||||
mBuffer = old;
|
mBuffer = old;
|
||||||
return false;
|
return false;
|
||||||
@ -1777,7 +1777,7 @@ WebSocketChannel::ProcessInput(uint8_t *buffer, uint32_t count)
|
|||||||
// release memory if we've been processing a large message
|
// release memory if we've been processing a large message
|
||||||
if (mBufferSize > kIncomingBufferStableSize) {
|
if (mBufferSize > kIncomingBufferStableSize) {
|
||||||
mBufferSize = kIncomingBufferStableSize;
|
mBufferSize = kIncomingBufferStableSize;
|
||||||
moz_free(mBuffer);
|
free(mBuffer);
|
||||||
mBuffer = (uint8_t *)moz_xmalloc(mBufferSize);
|
mBuffer = (uint8_t *)moz_xmalloc(mBufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ DataChannelConnection::SendOpenRequestMessage(const nsACString& label,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// FIX! need to set errno! Or make all these SendXxxx() funcs return 0 or errno!
|
// FIX! need to set errno! Or make all these SendXxxx() funcs return 0 or errno!
|
||||||
moz_free(req);
|
free(req);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (unordered) {
|
if (unordered) {
|
||||||
@ -1025,7 +1025,7 @@ DataChannelConnection::SendOpenRequestMessage(const nsACString& label,
|
|||||||
|
|
||||||
int32_t result = SendControlMessage(req, req_size, stream);
|
int32_t result = SendControlMessage(req, req_size, stream);
|
||||||
|
|
||||||
moz_free(req);
|
free(req);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1731,7 +1731,7 @@ DataChannelConnection::SendOutgoingStreamReset()
|
|||||||
} else {
|
} else {
|
||||||
mStreamsResetting.Clear();
|
mStreamsResetting.Clear();
|
||||||
}
|
}
|
||||||
moz_free(srs);
|
free(srs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
~QueuedDataMessage()
|
~QueuedDataMessage()
|
||||||
{
|
{
|
||||||
moz_free(mData);
|
free(mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t mStream;
|
uint16_t mStream;
|
||||||
|
@ -442,8 +442,8 @@ nsBinHexDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt)
|
|||||||
|
|
||||||
NS_ENSURE_TRUE(mNextListener, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(mNextListener, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
mDataBuffer = (char *) moz_malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
|
mDataBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
|
||||||
mOutgoingBuffer = (char *) moz_malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
|
mOutgoingBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
|
||||||
if (!mDataBuffer || !mOutgoingBuffer) return NS_ERROR_FAILURE; // out of memory;
|
if (!mDataBuffer || !mOutgoingBuffer) return NS_ERROR_FAILURE; // out of memory;
|
||||||
|
|
||||||
// now we want to create a pipe which we'll use to write our converted data...
|
// now we want to create a pipe which we'll use to write our converted data...
|
||||||
|
@ -151,20 +151,20 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
|
|||||||
|
|
||||||
if (mInpBuffer != nullptr && streamLen > mInpBufferLen)
|
if (mInpBuffer != nullptr && streamLen > mInpBufferLen)
|
||||||
{
|
{
|
||||||
mInpBuffer = (unsigned char *) moz_realloc(mInpBuffer, mInpBufferLen = streamLen);
|
mInpBuffer = (unsigned char *) realloc(mInpBuffer, mInpBufferLen = streamLen);
|
||||||
|
|
||||||
if (mOutBufferLen < streamLen * 2)
|
if (mOutBufferLen < streamLen * 2)
|
||||||
mOutBuffer = (unsigned char *) moz_realloc(mOutBuffer, mOutBufferLen = streamLen * 3);
|
mOutBuffer = (unsigned char *) realloc(mOutBuffer, mOutBufferLen = streamLen * 3);
|
||||||
|
|
||||||
if (mInpBuffer == nullptr || mOutBuffer == nullptr)
|
if (mInpBuffer == nullptr || mOutBuffer == nullptr)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInpBuffer == nullptr)
|
if (mInpBuffer == nullptr)
|
||||||
mInpBuffer = (unsigned char *) moz_malloc(mInpBufferLen = streamLen);
|
mInpBuffer = (unsigned char *) malloc(mInpBufferLen = streamLen);
|
||||||
|
|
||||||
if (mOutBuffer == nullptr)
|
if (mOutBuffer == nullptr)
|
||||||
mOutBuffer = (unsigned char *) moz_malloc(mOutBufferLen = streamLen * 3);
|
mOutBuffer = (unsigned char *) malloc(mOutBufferLen = streamLen * 3);
|
||||||
|
|
||||||
if (mInpBuffer == nullptr || mOutBuffer == nullptr)
|
if (mInpBuffer == nullptr || mOutBuffer == nullptr)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -480,7 +480,7 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
|
|||||||
{
|
{
|
||||||
(void *(*)(size_t))moz_xmalloc,
|
(void *(*)(size_t))moz_xmalloc,
|
||||||
(void *(*)(void *, size_t))moz_xrealloc,
|
(void *(*)(void *, size_t))moz_xrealloc,
|
||||||
moz_free
|
free
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char16_t kExpatSeparator[] = { 0xFFFF, '\0' };
|
static const char16_t kExpatSeparator[] = { 0xFFFF, '\0' };
|
||||||
|
@ -343,7 +343,7 @@ RDFContentSinkImpl::~RDFContentSinkImpl()
|
|||||||
|
|
||||||
delete mContextStack;
|
delete mContextStack;
|
||||||
}
|
}
|
||||||
moz_free(mText);
|
free(mText);
|
||||||
|
|
||||||
|
|
||||||
if (--gRefCnt == 0) {
|
if (--gRefCnt == 0) {
|
||||||
@ -755,7 +755,7 @@ RDFContentSinkImpl::AddText(const char16_t* aText, int32_t aLength)
|
|||||||
{
|
{
|
||||||
// Create buffer when we first need it
|
// Create buffer when we first need it
|
||||||
if (0 == mTextSize) {
|
if (0 == mTextSize) {
|
||||||
mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096);
|
mText = (char16_t *) malloc(sizeof(char16_t) * 4096);
|
||||||
if (!mText) {
|
if (!mText) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ RDFContentSinkImpl::AddText(const char16_t* aText, int32_t aLength)
|
|||||||
int32_t newSize = (2 * mTextSize > (mTextSize + aLength)) ?
|
int32_t newSize = (2 * mTextSize > (mTextSize + aLength)) ?
|
||||||
(2 * mTextSize) : (mTextSize + aLength);
|
(2 * mTextSize) : (mTextSize + aLength);
|
||||||
char16_t* newText =
|
char16_t* newText =
|
||||||
(char16_t *) moz_realloc(mText, sizeof(char16_t) * newSize);
|
(char16_t *) realloc(mText, sizeof(char16_t) * newSize);
|
||||||
if (!newText)
|
if (!newText)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
mTextSize = newSize;
|
mTextSize = newSize;
|
||||||
|
@ -609,7 +609,7 @@ nsHTTPListener::~nsHTTPListener()
|
|||||||
send_done_signal();
|
send_done_signal();
|
||||||
|
|
||||||
if (mResultData) {
|
if (mResultData) {
|
||||||
moz_free(const_cast<uint8_t *>(mResultData));
|
free(const_cast<uint8_t *>(mResultData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLoader) {
|
if (mLoader) {
|
||||||
|
@ -402,10 +402,10 @@ namespace {
|
|||||||
// allocated for a given request. SQLite uses this function before all
|
// allocated for a given request. SQLite uses this function before all
|
||||||
// allocations, and may be able to use any excess bytes caused by the rounding.
|
// allocations, and may be able to use any excess bytes caused by the rounding.
|
||||||
//
|
//
|
||||||
// Note: the wrappers for moz_malloc, moz_realloc and moz_malloc_usable_size
|
// Note: the wrappers for malloc, realloc and moz_malloc_usable_size are
|
||||||
// are necessary because the sqlite_mem_methods type signatures differ slightly
|
// necessary because the sqlite_mem_methods type signatures differ slightly
|
||||||
// from the standard ones -- they use int instead of size_t. But we don't need
|
// from the standard ones -- they use int instead of size_t. But we don't need
|
||||||
// a wrapper for moz_free.
|
// a wrapper for free.
|
||||||
|
|
||||||
#ifdef MOZ_DMD
|
#ifdef MOZ_DMD
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(SqliteMallocSizeOfOnFree)
|
|||||||
|
|
||||||
static void *sqliteMemMalloc(int n)
|
static void *sqliteMemMalloc(int n)
|
||||||
{
|
{
|
||||||
void* p = ::moz_malloc(n);
|
void* p = ::malloc(n);
|
||||||
#ifdef MOZ_DMD
|
#ifdef MOZ_DMD
|
||||||
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
|
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
|
||||||
#endif
|
#endif
|
||||||
@ -441,14 +441,14 @@ static void sqliteMemFree(void *p)
|
|||||||
#ifdef MOZ_DMD
|
#ifdef MOZ_DMD
|
||||||
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
||||||
#endif
|
#endif
|
||||||
::moz_free(p);
|
::free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *sqliteMemRealloc(void *p, int n)
|
static void *sqliteMemRealloc(void *p, int n)
|
||||||
{
|
{
|
||||||
#ifdef MOZ_DMD
|
#ifdef MOZ_DMD
|
||||||
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
|
||||||
void *pnew = ::moz_realloc(p, n);
|
void *pnew = ::realloc(p, n);
|
||||||
if (pnew) {
|
if (pnew) {
|
||||||
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(pnew);
|
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(pnew);
|
||||||
} else {
|
} else {
|
||||||
@ -457,7 +457,7 @@ static void *sqliteMemRealloc(void *p, int n)
|
|||||||
}
|
}
|
||||||
return pnew;
|
return pnew;
|
||||||
#else
|
#else
|
||||||
return ::moz_realloc(p, n);
|
return ::realloc(p, n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ NS_Realloc(void* aPtr, size_t aSize)
|
|||||||
XPCOM_API(void)
|
XPCOM_API(void)
|
||||||
NS_Free(void* aPtr)
|
NS_Free(void* aPtr)
|
||||||
{
|
{
|
||||||
moz_free(aPtr);
|
free(aPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -167,13 +167,13 @@ struct nsTArrayInfallibleAllocatorBase
|
|||||||
|
|
||||||
struct nsTArrayFallibleAllocator : nsTArrayFallibleAllocatorBase
|
struct nsTArrayFallibleAllocator : nsTArrayFallibleAllocatorBase
|
||||||
{
|
{
|
||||||
static void* Malloc(size_t aSize) { return moz_malloc(aSize); }
|
static void* Malloc(size_t aSize) { return malloc(aSize); }
|
||||||
static void* Realloc(void* aPtr, size_t aSize)
|
static void* Realloc(void* aPtr, size_t aSize)
|
||||||
{
|
{
|
||||||
return moz_realloc(aPtr, aSize);
|
return realloc(aPtr, aSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Free(void* aPtr) { moz_free(aPtr); }
|
static void Free(void* aPtr) { free(aPtr); }
|
||||||
static void SizeTooBig(size_t) {}
|
static void SizeTooBig(size_t) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ struct nsTArrayInfallibleAllocator : nsTArrayInfallibleAllocatorBase
|
|||||||
return moz_xrealloc(aPtr, aSize);
|
return moz_xrealloc(aPtr, aSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Free(void* aPtr) { moz_free(aPtr); }
|
static void Free(void* aPtr) { free(aPtr); }
|
||||||
static void SizeTooBig(size_t aSize) { NS_ABORT_OOM(aSize); }
|
static void SizeTooBig(size_t aSize) { NS_ABORT_OOM(aSize); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString)
|
|||||||
if (length <= 64) {
|
if (length <= 64) {
|
||||||
copy = temp;
|
copy = temp;
|
||||||
} else {
|
} else {
|
||||||
copy = reinterpret_cast<char16_t*>(moz_malloc(byteCount));
|
copy = reinterpret_cast<char16_t*>(malloc(byteCount));
|
||||||
if (!copy) {
|
if (!copy) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString)
|
|||||||
mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
|
mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
|
||||||
rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
|
rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
|
||||||
if (copy != temp) {
|
if (copy != temp) {
|
||||||
moz_free(copy);
|
free(copy);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -798,18 +798,18 @@ nsBinaryInputStream::ReadBytes(uint32_t aLength, char** aResult)
|
|||||||
uint32_t bytesRead;
|
uint32_t bytesRead;
|
||||||
char* s;
|
char* s;
|
||||||
|
|
||||||
s = reinterpret_cast<char*>(moz_malloc(aLength));
|
s = reinterpret_cast<char*>(malloc(aLength));
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = Read(s, aLength, &bytesRead);
|
rv = Read(s, aLength, &bytesRead);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
moz_free(s);
|
free(s);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if (bytesRead != aLength) {
|
if (bytesRead != aLength) {
|
||||||
moz_free(s);
|
free(s);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,7 +1745,7 @@ nsLocalFile::GetVersionInfoField(const char* aField, nsAString& aResult)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
moz_free(ver);
|
free(ver);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ nsScriptableInputStream::Read(uint32_t aCount, char** aResult)
|
|||||||
// bug716556 - Ensure count+1 doesn't overflow
|
// bug716556 - Ensure count+1 doesn't overflow
|
||||||
uint32_t count =
|
uint32_t count =
|
||||||
XPCOM_MIN((uint32_t)XPCOM_MIN<uint64_t>(count64, aCount), UINT32_MAX - 1);
|
XPCOM_MIN((uint32_t)XPCOM_MIN<uint64_t>(count64, aCount), UINT32_MAX - 1);
|
||||||
buffer = (char*)moz_malloc(count + 1); // make room for '\0'
|
buffer = (char*)malloc(count + 1); // make room for '\0'
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ nsSegmentedBuffer::AppendNewSegment()
|
|||||||
mSegmentArrayCount = newArraySize;
|
mSegmentArrayCount = newArraySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* seg = (char*)moz_malloc(mSegmentSize);
|
char* seg = (char*)malloc(mSegmentSize);
|
||||||
if (!seg) {
|
if (!seg) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ bool
|
|||||||
nsSegmentedBuffer::DeleteFirstSegment()
|
nsSegmentedBuffer::DeleteFirstSegment()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mSegmentArray[mFirstSegmentIndex] != nullptr, "deleting bad segment");
|
NS_ASSERTION(mSegmentArray[mFirstSegmentIndex] != nullptr, "deleting bad segment");
|
||||||
moz_free(mSegmentArray[mFirstSegmentIndex]);
|
free(mSegmentArray[mFirstSegmentIndex]);
|
||||||
mSegmentArray[mFirstSegmentIndex] = nullptr;
|
mSegmentArray[mFirstSegmentIndex] = nullptr;
|
||||||
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
||||||
if (mFirstSegmentIndex == last) {
|
if (mFirstSegmentIndex == last) {
|
||||||
@ -94,7 +94,7 @@ nsSegmentedBuffer::DeleteLastSegment()
|
|||||||
{
|
{
|
||||||
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
||||||
NS_ASSERTION(mSegmentArray[last] != nullptr, "deleting bad segment");
|
NS_ASSERTION(mSegmentArray[last] != nullptr, "deleting bad segment");
|
||||||
moz_free(mSegmentArray[last]);
|
free(mSegmentArray[last]);
|
||||||
mSegmentArray[last] = nullptr;
|
mSegmentArray[last] = nullptr;
|
||||||
mLastSegmentIndex = last;
|
mLastSegmentIndex = last;
|
||||||
return (bool)(mLastSegmentIndex == mFirstSegmentIndex);
|
return (bool)(mLastSegmentIndex == mFirstSegmentIndex);
|
||||||
@ -105,7 +105,7 @@ nsSegmentedBuffer::ReallocLastSegment(size_t aNewSize)
|
|||||||
{
|
{
|
||||||
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
|
||||||
NS_ASSERTION(mSegmentArray[last] != nullptr, "realloc'ing bad segment");
|
NS_ASSERTION(mSegmentArray[last] != nullptr, "realloc'ing bad segment");
|
||||||
char* newSegment = (char*)moz_realloc(mSegmentArray[last], aNewSize);
|
char* newSegment = (char*)realloc(mSegmentArray[last], aNewSize);
|
||||||
if (newSegment) {
|
if (newSegment) {
|
||||||
mSegmentArray[last] = newSegment;
|
mSegmentArray[last] = newSegment;
|
||||||
return true;
|
return true;
|
||||||
@ -119,7 +119,7 @@ nsSegmentedBuffer::Empty()
|
|||||||
if (mSegmentArray) {
|
if (mSegmentArray) {
|
||||||
for (uint32_t i = 0; i < mSegmentArrayCount; i++) {
|
for (uint32_t i = 0; i < mSegmentArrayCount; i++) {
|
||||||
if (mSegmentArray[i]) {
|
if (mSegmentArray[i]) {
|
||||||
moz_free(mSegmentArray[i]);
|
free(mSegmentArray[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nsMemory::Free(mSegmentArray);
|
nsMemory::Free(mSegmentArray);
|
||||||
|
@ -31,8 +31,8 @@ if CONFIG['_MSC_VER']:
|
|||||||
CFLAGS += ['-Zl']
|
CFLAGS += ['-Zl']
|
||||||
|
|
||||||
# Code with FINAL_LIBRARY = 'xul' shouldn't do this, but the code
|
# Code with FINAL_LIBRARY = 'xul' shouldn't do this, but the code
|
||||||
# here doesn't use moz_malloc functions anyways, while not setting
|
# here doesn't use malloc functions anyways, while not setting
|
||||||
# MOZ_NO_MOZALLOC makes the code include mozalloc.h, which includes
|
# MOZ_NO_MOZALLOC makes the code include mozalloc.h, which includes
|
||||||
# inline operator new definitions that MSVC linker doesn't strip
|
# inline operator new definitions that MSVC linker doesn't strip
|
||||||
# when linking the xpt tests without mozalloc.
|
# when linking the xpt tests.
|
||||||
DEFINES['MOZ_NO_MOZALLOC'] = True
|
DEFINES['MOZ_NO_MOZALLOC'] = True
|
||||||
|
Loading…
Reference in New Issue
Block a user