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:
Mike Hommey 2015-02-19 13:51:06 +09:00
parent 39830fa50a
commit 95e047925a
71 changed files with 199 additions and 200 deletions

View File

@ -20,7 +20,7 @@ public:
~BlobSet()
{
moz_free(mData);
free(mData);
}
nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
@ -52,7 +52,7 @@ protected:
if (!bufferLen.isValid())
return false;
void* data = moz_realloc(mData, bufferLen.value());
void* data = realloc(mData, bufferLen.value());
if (!data)
return false;

View File

@ -84,7 +84,7 @@ public:
uint64_t aLength);
// 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.
static already_AddRefed<File>
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
@ -92,7 +92,7 @@ public:
uint64_t aLastModifiedDate);
// 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.
static already_AddRefed<File>
CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer, uint64_t aLength,
@ -552,7 +552,7 @@ public:
sDataOwners = nullptr;
}
moz_free(mData);
free(mData);
}
public:

View File

@ -102,7 +102,7 @@ nsAttrAndChildArray::~nsAttrAndChildArray()
Clear();
moz_free(mImpl);
free(mImpl);
}
nsIContent*
@ -635,11 +635,11 @@ nsAttrAndChildArray::Compact()
// Then resize or free buffer
uint32_t newSize = attrCount * ATTRSIZE + childCount;
if (!newSize && !mImpl->mMappedAttrs) {
moz_free(mImpl);
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*>(realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
mImpl->mBufferSize = newSize;
@ -776,7 +776,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*>(realloc(mImpl, size * sizeof(void*)));
NS_ENSURE_TRUE(newImpl, false);
mImpl = newImpl;

View File

@ -6052,7 +6052,7 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
JS::MutableHandle<JS::Value> aBlob)
{
uint32_t blobLen = aData.Length();
void* blobData = moz_malloc(blobLen);
void* blobData = malloc(blobLen);
nsRefPtr<File> blob;
if (blobData) {
memcpy(blobData, aData.BeginReading(), blobLen);

View File

@ -363,7 +363,7 @@ nsDOMFileReader::DoReadData(nsIAsyncInputStream* aStream, uint64_t aCount)
return NS_ERROR_OUT_OF_MEMORY;
}
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);
}

View File

@ -131,7 +131,7 @@ protected:
nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, uint32_t aDataLen, nsAString &aResult);
void FreeFileData() {
moz_free(mFileData);
free(mFileData);
mFileData = nullptr;
mDataLen = 0;
}

View File

@ -1461,7 +1461,7 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
}
rv = NS_OK;
} else {
moz_free(const_cast<uint8_t *>(aString));
free(const_cast<uint8_t *>(aString));
rv = NS_SUCCESS_ADOPTED_DATA;
}

View File

@ -84,7 +84,7 @@ void
nsTextFragment::ReleaseText()
{
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;
@ -107,7 +107,7 @@ nsTextFragment::operator=(const nsTextFragment& aOther)
size_t m2bSize = aOther.mState.mLength *
(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) {
memcpy(m2b, aOther.m2b, m2bSize);
} 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
// Use ucs2 storage because we have to
size_t m2bSize = aLength * sizeof(char16_t);
m2b = (char16_t *)moz_malloc(m2bSize);
m2b = (char16_t *)malloc(m2bSize);
if (!m2b) {
return false;
}
@ -268,7 +268,7 @@ nsTextFragment::SetTo(const char16_t* aBuffer, int32_t aLength, bool aUpdateBidi
} else {
// Use 1 byte storage because we can
char* buff = (char *)moz_malloc(aLength * sizeof(char));
char* buff = (char *)malloc(aLength * sizeof(char));
if (!buff) {
return false;
}
@ -326,7 +326,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
if (mState.mIs2b) {
// 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) {
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
// The old data was 1-byte, but the new is not so we have to expand it
// all to 2-byte
char16_t* buff = (char16_t*)moz_malloc((mState.mLength + aLength) *
sizeof(char16_t));
char16_t* buff =
(char16_t*)malloc((mState.mLength + aLength) * sizeof(char16_t));
if (!buff) {
return false;
}
@ -363,7 +363,7 @@ nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength, bool aUpdateBi
mState.mIs2b = true;
if (mState.mInHeap) {
moz_free(m2b);
free(m2b);
}
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
char* buff;
if (mState.mInHeap) {
buff = (char*)moz_realloc(const_cast<char*>(m1b),
(mState.mLength + aLength) * sizeof(char));
buff = (char*)realloc(const_cast<char*>(m1b),
(mState.mLength + aLength) * sizeof(char));
if (!buff) {
return false;
}
}
else {
buff = (char*)moz_malloc((mState.mLength + aLength) * sizeof(char));
buff = (char*)malloc((mState.mLength + aLength) * sizeof(char));
if (!buff) {
return false;
}

View File

@ -174,7 +174,7 @@ WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
if (!boundBuffer)
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)
return ErrorOutOfMemory("bufferData: out of memory");

View File

@ -674,7 +674,7 @@ public:
~AutoFreeBuffer()
{
moz_free(mBuffer);
free(mBuffer);
}
void

View File

@ -14785,14 +14785,14 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
reinterpret_cast<const char*>(mParams.cloneInfo().data().Elements());
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.
{
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.
char* compressed = static_cast<char*>(moz_malloc(compressedLength));
char* compressed = static_cast<char*>(malloc(compressedLength));
if (NS_WARN_IF(!compressed)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -14808,7 +14808,7 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(TransactionBase* aTransaction)
rv = stmt->BindAdoptedBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
dataBufferLength);
if (NS_WARN_IF(NS_FAILED(rv))) {
moz_free(compressed);
free(compressed);
return rv;
}
}

View File

@ -836,7 +836,7 @@ CreateBlobImpl(const nsTArray<uint8_t>& aMemoryData,
return nullptr;
}
void* buffer = moz_malloc(length * elementSizeMultiplier);
void* buffer = malloc(length * elementSizeMultiplier);
if (NS_WARN_IF(!buffer)) {
return nullptr;
}

View File

@ -54,7 +54,7 @@ EncodedBufferCache::ExtractBlob(nsISupports* aParent,
mDataSize = 0;
mFD = nullptr;
} else {
void* blobData = moz_malloc(mDataSize);
void* blobData = malloc(mDataSize);
NS_ASSERTION(blobData, "out of memory!!");
if (blobData) {

View File

@ -255,7 +255,7 @@ AnalyserNode::FFTAnalysis()
if (mWriteIndex == 0) {
inputBuffer = mBuffer.Elements();
} else {
inputBuffer = static_cast<float*>(moz_malloc(FftSize() * sizeof(float)));
inputBuffer = static_cast<float*>(malloc(FftSize() * sizeof(float)));
if (!inputBuffer) {
return false;
}
@ -280,7 +280,7 @@ AnalyserNode::FFTAnalysis()
}
if (allocated) {
moz_free(inputBuffer);
free(inputBuffer);
}
return true;
}

View File

@ -52,7 +52,7 @@ private:
uint32_t mChunkSize;
// 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;
};

View File

@ -603,7 +603,7 @@ MediaEngineGonkVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLeng
: mPhotoDataLength(aLength)
{
mCallbacks.SwapElements(aCallbacks);
mPhotoData = (uint8_t*) moz_malloc(aLength);
mPhotoData = (uint8_t*) malloc(aLength);
memcpy(mPhotoData, aData, mPhotoDataLength);
mMimeType = aMimeType;
}

View File

@ -67,7 +67,7 @@ AudioOutputObserver::AudioOutputObserver()
AudioOutputObserver::~AudioOutputObserver()
{
Clear();
moz_free(mSaved);
free(mSaved);
mSaved = nullptr;
}
@ -75,7 +75,7 @@ void
AudioOutputObserver::Clear()
{
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
}
@ -544,7 +544,7 @@ MediaEngineWebRTCAudioSource::Process(int channel,
if (!mStarted) {
mStarted = true;
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(),
mPlayoutDelay,
length);
moz_free(buffer);
free(buffer);
if (res == -1) {
return;
}

View File

@ -265,13 +265,13 @@ NSCursorInfo::NSCursorInfo(const Cursor* aCursor)
}
}
moz_free(bitmap);
free(bitmap);
}
NSCursorInfo::~NSCursorInfo()
{
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.
if (!retval) {
@ -528,7 +528,7 @@ void NSCursorInfo::SetHotSpot(nsPoint aHotSpot)
void NSCursorInfo::SetCustomImageData(uint8_t* aData, uint32_t aDataLength)
{
if (mCustomImageData) {
moz_free(mCustomImageData);
free(mCustomImageData);
}
if (aDataLength) {
mCustomImageData = (uint8_t*) moz_xmalloc(aDataLength);

View File

@ -184,7 +184,7 @@ XULContentSinkImpl::~XULContentSinkImpl()
NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
mContextStack.Clear();
moz_free(mText);
free(mText);
}
//----------------------------------------------------------------------
@ -1051,7 +1051,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
{
// Create buffer when we first need it
if (0 == mTextSize) {
mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096);
mText = (char16_t *) malloc(sizeof(char16_t) * 4096);
if (nullptr == mText) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1074,7 +1074,7 @@ XULContentSinkImpl::AddText(const char16_t* aText,
}
else {
mTextSize += aLength;
mText = (char16_t *) moz_realloc(mText, sizeof(char16_t) * mTextSize);
mText = (char16_t *) realloc(mText, sizeof(char16_t) * mTextSize);
if (nullptr == mText) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -134,14 +134,14 @@ struct AlignedArray
}
#endif
moz_free(mStorage);
free(mStorage);
mStorage = nullptr;
mPtr = nullptr;
}
MOZ_ALWAYS_INLINE void Realloc(size_t aCount, bool aZero = false)
{
moz_free(mStorage);
free(mStorage);
CheckedInt32 storageByteCount =
CheckedInt32(sizeof(T)) * aCount + (alignment - 1);
if (!storageByteCount.isValid()) {
@ -155,9 +155,9 @@ struct AlignedArray
if (aZero) {
// calloc can be more efficient than new[] for large chunks,
// 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 {
mStorage = static_cast<uint8_t *>(moz_malloc(storageByteCount.value()));
mStorage = static_cast<uint8_t *>(malloc(storageByteCount.value()));
}
if (!mStorage) {
mStorage = nullptr;

View File

@ -6,7 +6,7 @@
#ifndef 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
// allocation failures reliably.
@ -15,6 +15,5 @@
#define malloc moz_xmalloc
#define calloc moz_xcalloc
#define realloc moz_xrealloc
#define free moz_free
#endif // MOZ_GR_MALLOC_H

View File

@ -64,10 +64,10 @@ index 0000000..1f16ee5
+}
+
+void sk_free(void* p) {
+ moz_free(p);
+ free(p);
+}
+
+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);
+}
+

View File

@ -31,15 +31,15 @@ void* sk_realloc_throw(void* addr, size_t size) {
}
void sk_free(void* p) {
moz_free(p);
free(p);
}
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) {
return moz_calloc(size, 1);
return calloc(size, 1);
}
void* sk_calloc_throw(size_t size) {

View File

@ -107,7 +107,7 @@ public:
NS_ASSERTION(item, "failed to find zip entry");
uint32_t bufSize = item->RealSize();
mFontDataBuf = static_cast<uint8_t*>(moz_malloc(bufSize));
mFontDataBuf = static_cast<uint8_t*>(malloc(bufSize));
if (mFontDataBuf) {
nsZipCursor cursor(item, reader, mFontDataBuf, bufSize);
cursor.Copy(&bufSize);
@ -136,7 +136,7 @@ public:
if (mFace && mOwnsFace) {
FT_Done_Face(mFace);
if (mFontDataBuf) {
moz_free(mFontDataBuf);
free(mFontDataBuf);
}
}
}

View File

@ -1152,7 +1152,7 @@ public:
uint32_t size =
offsetof(gfxShapedWord, mCharGlyphsStorage) +
aLength * (sizeof(CompressedGlyph) + sizeof(uint8_t));
void *storage = moz_malloc(size);
void *storage = malloc(size);
if (!storage) {
return nullptr;
}
@ -1183,7 +1183,7 @@ public:
uint32_t size =
offsetof(gfxShapedWord, mCharGlyphsStorage) +
aLength * (sizeof(CompressedGlyph) + sizeof(char16_t));
void *storage = moz_malloc(size);
void *storage = malloc(size);
if (!storage) {
return nullptr;
}
@ -1193,9 +1193,9 @@ public:
}
// Override operator delete to properly free the object that was
// allocated via moz_malloc.
// allocated via malloc.
void operator delete(void* p) {
moz_free(p);
free(p);
}
virtual CompressedGlyph *GetCharacterGlyphs() override {

View File

@ -95,7 +95,7 @@ TryAllocAlignedBytes(size_t aSize)
nullptr : ptr;
#else
// Oh well, hope that luck is with us in the allocator
return moz_malloc(aSize);
return malloc(aSize);
#endif
}

View File

@ -106,7 +106,7 @@ gfxTextRun::AllocateStorageForTextRun(size_t aSize, uint32_t aLength)
{
// Allocate the storage we need, returning nullptr on failure rather than
// 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) {
NS_WARNING("failed to allocate storage for text run!");
return nullptr;

View File

@ -82,9 +82,9 @@ class gfxTextRun : public gfxShapedText {
public:
// Override operator delete to properly free the object that was
// allocated via moz_malloc.
// allocated via malloc.
void operator delete(void* p) {
moz_free(p);
free(p);
}
virtual ~gfxTextRun();

View File

@ -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
// sanitized copy
moz_free((void*)aFontData);
free((void*)aFontData);
return fe != nullptr;
}
@ -690,7 +690,7 @@ gfxUserFontEntry::Load()
// This is called when a font download finishes.
// 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
gfxUserFontEntry::FontDataDownloadComplete(const uint8_t* aFontData,
uint32_t aLength,
@ -718,7 +718,7 @@ gfxUserFontEntry::FontDataDownloadComplete(const uint8_t* aFontData,
}
if (aFontData) {
moz_free((void*)aFontData);
free((void*)aFontData);
}
// error occurred, load next src

View File

@ -60,7 +60,7 @@ nsBMPDecoder::~nsBMPDecoder()
{
delete[] mColors;
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 &&
mBIH.compression != BI_ALPHABITFIELDS) {
// 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
// I don't want to make exact calculations here, that's unnecessary.
// Also, it compensates rounding error.

View File

@ -93,8 +93,8 @@ nsGIFDecoder2::nsGIFDecoder2(RasterImage* aImage)
nsGIFDecoder2::~nsGIFDecoder2()
{
moz_free(mGIFStruct.local_colormap);
moz_free(mGIFStruct.hold);
free(mGIFStruct.local_colormap);
free(mGIFStruct.hold);
}
void
@ -1161,8 +1161,8 @@ nsGIFDecoder2::SetHold(const uint8_t* buf1, uint32_t count1,
uint32_t count2 /* = 0 */)
{
// 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),
count1 + count2));
uint8_t* newHold = (uint8_t*) malloc(std::max(uint32_t(MIN_HOLD_SIZE),
count1 + count2));
if (!newHold) {
mGIFStruct.state = gif_error;
return false;
@ -1173,7 +1173,7 @@ nsGIFDecoder2::SetHold(const uint8_t* buf1, uint32_t count1,
memcpy(newHold + count1, buf2, count2);
}
moz_free(mGIFStruct.hold);
free(mGIFStruct.hold);
mGIFStruct.hold = newHold;
mGIFStruct.bytes_in_hold = count1 + count2;
return true;

View File

@ -70,7 +70,7 @@ nsICODecoder::nsICODecoder(RasterImage* aImage)
nsICODecoder::~nsICODecoder()
{
if (mRow) {
moz_free(mRow);
free(mRow);
}
}
@ -530,7 +530,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
mPos++;
mRowBytes = 0;
mCurLine = GetRealHeight();
mRow = (uint8_t*)moz_realloc(mRow, rowSize);
mRow = (uint8_t*)realloc(mRow, rowSize);
if (!mRow) {
PostDecoderError(NS_ERROR_OUT_OF_MEMORY);
return;

View File

@ -661,7 +661,7 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
(channels <= 2 || interlace_type == PNG_INTERLACE_ADAM7)) {
uint32_t bpp[] = { 0, 3, 4, 3, 4 };
decoder->mCMSLine =
(uint8_t*)moz_malloc(bpp[channels] * width);
(uint8_t*)malloc(bpp[channels] * width);
if (!decoder->mCMSLine) {
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 (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) {
png_longjmp(decoder->mPNG, 5); // NS_ERROR_OUT_OF_MEMORY

View File

@ -30,7 +30,7 @@ nsBMPEncoder::nsBMPEncoder() : mImageBufferStart(nullptr),
nsBMPEncoder::~nsBMPEncoder()
{
if (mImageBufferStart) {
moz_free(mImageBufferStart);
free(mImageBufferStart);
mImageBufferStart = nullptr;
mImageBufferCurr = nullptr;
}
@ -133,7 +133,7 @@ nsBMPEncoder::StartImageEncode(uint32_t aWidth,
InitInfoHeader(version, bpp, aWidth, aHeight);
mImageBufferSize = mBMPFileHeader.filesize;
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
if (!mImageBufferStart) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -316,7 +316,7 @@ NS_IMETHODIMP
nsBMPEncoder::Close()
{
if (mImageBufferStart) {
moz_free(mImageBufferStart);
free(mImageBufferStart);
mImageBufferStart = nullptr;
mImageBufferSize = 0;
mImageBufferReadPoint = 0;

View File

@ -31,7 +31,7 @@ nsICOEncoder::nsICOEncoder() : mImageBufferStart(nullptr),
nsICOEncoder::~nsICOEncoder()
{
if (mImageBufferStart) {
moz_free(mImageBufferStart);
free(mImageBufferStart);
mImageBufferStart = nullptr;
mImageBufferCurr = nullptr;
}
@ -120,7 +120,7 @@ nsICOEncoder::AddImageFrame(const uint8_t* aData,
mContainedEncoder->GetImageBufferUsed(&PNGImageBufferSize);
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
PNGImageBufferSize;
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
if (!mImageBufferStart) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -154,7 +154,7 @@ nsICOEncoder::AddImageFrame(const uint8_t* aData,
mContainedEncoder->GetImageBufferUsed(&BMPImageBufferSize);
mImageBufferSize = ICONFILEHEADERSIZE + ICODIRENTRYSIZE +
BMPImageBufferSize + andMaskSize;
mImageBufferStart = static_cast<uint8_t*>(moz_malloc(mImageBufferSize));
mImageBufferStart = static_cast<uint8_t*>(malloc(mImageBufferSize));
if (!mImageBufferStart) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -334,7 +334,7 @@ NS_IMETHODIMP
nsICOEncoder::Close()
{
if (mImageBufferStart) {
moz_free(mImageBufferStart);
free(mImageBufferStart);
mImageBufferStart = nullptr;
mImageBufferSize = 0;
mImageBufferReadPoint = 0;

View File

@ -39,7 +39,7 @@ nsJPEGEncoder::nsJPEGEncoder()
nsJPEGEncoder::~nsJPEGEncoder()
{
if (mImageBuffer) {
moz_free(mImageBuffer);
free(mImageBuffer);
mImageBuffer = nullptr;
}
}
@ -243,7 +243,7 @@ NS_IMETHODIMP
nsJPEGEncoder::Close()
{
if (mImageBuffer != nullptr) {
moz_free(mImageBuffer);
free(mImageBuffer);
mImageBuffer = nullptr;
mImageBufferSize = 0;
mImageBufferUsed = 0;
@ -404,7 +404,7 @@ nsJPEGEncoder::initDestination(jpeg_compress_struct* cinfo)
NS_ASSERTION(!that->mImageBuffer, "Image buffer already initialized");
that->mImageBufferSize = 8192;
that->mImageBuffer = (uint8_t*)moz_malloc(that->mImageBufferSize);
that->mImageBuffer = (uint8_t*)malloc(that->mImageBufferSize);
that->mImageBufferUsed = 0;
cinfo->dest->next_output_byte = that->mImageBuffer;
@ -438,11 +438,11 @@ nsJPEGEncoder::emptyOutputBuffer(jpeg_compress_struct* cinfo)
// expand buffer, just double size each time
that->mImageBufferSize *= 2;
uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
that->mImageBufferSize);
uint8_t* newBuf = (uint8_t*)realloc(that->mImageBuffer,
that->mImageBufferSize);
if (!newBuf) {
// can't resize, just zero (this will keep us from writing more)
moz_free(that->mImageBuffer);
free(that->mImageBuffer);
that->mImageBuffer = nullptr;
that->mImageBufferSize = 0;
that->mImageBufferUsed = 0;

View File

@ -42,7 +42,7 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(nullptr), mPNGinfo(nullptr),
nsPNGEncoder::~nsPNGEncoder()
{
if (mImageBuffer) {
moz_free(mImageBuffer);
free(mImageBuffer);
mImageBuffer = nullptr;
}
// 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
// in this function. It will be freed on object destruction.
mImageBufferSize = 8192;
mImageBuffer = (uint8_t*)moz_malloc(mImageBufferSize);
mImageBuffer = (uint8_t*)malloc(mImageBufferSize);
if (!mImageBuffer) {
png_destroy_write_struct(&mPNG, &mPNGinfo);
return NS_ERROR_OUT_OF_MEMORY;
@ -532,7 +532,7 @@ NS_IMETHODIMP
nsPNGEncoder::Close()
{
if (mImageBuffer != nullptr) {
moz_free(mImageBuffer);
free(mImageBuffer);
mImageBuffer = nullptr;
mImageBufferSize = 0;
mImageBufferUsed = 0;
@ -733,11 +733,11 @@ nsPNGEncoder::WriteCallback(png_structp png, png_bytep data,
// expand buffer, just double each time
that->mImageBufferSize *= 2;
uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
that->mImageBufferSize);
uint8_t* newBuf = (uint8_t*)realloc(that->mImageBuffer,
that->mImageBufferSize);
if (!newBuf) {
// can't resize, just zero (this will keep us from writing more)
moz_free(that->mImageBuffer);
free(that->mImageBuffer);
that->mImageBuffer = nullptr;
that->mImageBufferSize = 0;
that->mImageBufferUsed = 0;

View File

@ -161,7 +161,7 @@ imgFrame::~imgFrame()
MOZ_ASSERT(mAborted || IsImageCompleteInternal());
#endif
moz_free(mPalettedImageData);
free(mPalettedImageData);
mPalettedImageData = nullptr;
}
@ -213,7 +213,7 @@ imgFrame::ReinitForDecoder(const nsIntSize& aImageSize,
mOptSurface = nullptr;
mVBuf = nullptr;
mVBufPtr = nullptr;
moz_free(mPalettedImageData);
free(mPalettedImageData);
mPalettedImageData = nullptr;
// Reinitialize.
@ -274,10 +274,10 @@ imgFrame::InitForDecoder(const nsIntSize& aImageSize,
// Use the fallible allocator here. Paletted images always use 1 byte per
// pixel, so calculating the amount of memory we need is straightforward.
mPalettedImageData =
static_cast<uint8_t*>(moz_malloc(PaletteDataLength() +
(mSize.width * mSize.height)));
static_cast<uint8_t*>(malloc(PaletteDataLength() +
(mSize.width * mSize.height)));
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);
} else {
MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitForDecoder() twice?");

View File

@ -14,7 +14,7 @@
#define hnj_malloc(size) moz_xmalloc(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,

View File

@ -40,12 +40,12 @@ nsCollationMacUC::~nsCollationMacUC()
NS_ASSERTION(NS_SUCCEEDED(res), "CleanUpCollator failed");
if (mUseICU) {
if (mLocaleICU) {
moz_free(mLocaleICU);
free(mLocaleICU);
mLocaleICU = nullptr;
}
} else {
if (mBuffer) {
moz_free(mBuffer);
free(mBuffer);
mBuffer = nullptr;
}
}
@ -111,7 +111,7 @@ nsresult nsCollationMacUC::ConvertLocaleICU(nsILocale* aNSLocale, char** aICULoc
NS_ERROR_FAILURE);
NS_LossyConvertUTF16toASCII tmp(localeString);
tmp.ReplaceChar('-', '_');
char* locale = (char*)moz_malloc(tmp.Length() + 1);
char* locale = (char*)malloc(tmp.Length() + 1);
if (!locale) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -273,13 +273,13 @@ NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsASt
do {
newBufferLen *= 2;
} while (newBufferLen < maxKeyLen);
void* newBuffer = moz_malloc(newBufferLen);
void* newBuffer = malloc(newBufferLen);
if (!newBuffer) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (mBuffer) {
moz_free(mBuffer);
free(mBuffer);
mBuffer = nullptr;
}
mBuffer = newBuffer;

View File

@ -39,7 +39,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc
const nsAFlatString& flatSrc = PromiseFlatString(aSrc);
rv = mEncoder->GetMaxLength(flatSrc.get(), inLength, aOutLen);
if (NS_SUCCEEDED(rv)) {
*_retval = (char*)moz_malloc(*aOutLen+1);
*_retval = (char*)malloc(*aOutLen+1);
if (!*_retval)
return NS_ERROR_OUT_OF_MEMORY;
@ -49,7 +49,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc
(*_retval)[*aOutLen] = '\0';
return NS_OK;
}
moz_free(*_retval);
free(*_retval);
}
*_retval = nullptr;
return NS_ERROR_FAILURE;
@ -68,7 +68,7 @@ nsScriptableUnicodeConverter::ConvertFromUnicode(const nsAString& aSrc,
if (!_retval.Assign(str, len, mozilla::fallible)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
moz_free(str);
free(str);
}
return rv;
}
@ -81,7 +81,7 @@ nsScriptableUnicodeConverter::FinishWithLength(char **_retval, int32_t* aLength)
int32_t finLength = 32;
*_retval = (char *)moz_malloc(finLength);
*_retval = (char *)malloc(finLength);
if (!*_retval)
return NS_ERROR_OUT_OF_MEMORY;
@ -89,7 +89,7 @@ nsScriptableUnicodeConverter::FinishWithLength(char **_retval, int32_t* aLength)
if (NS_SUCCEEDED(rv))
*aLength = finLength;
else
moz_free(*_retval);
free(*_retval);
return rv;
@ -117,7 +117,7 @@ nsScriptableUnicodeConverter::Finish(nsACString& _retval)
if (!_retval.Assign(str, len, mozilla::fallible)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
moz_free(str);
free(str);
}
return rv;
}
@ -151,7 +151,7 @@ nsScriptableUnicodeConverter::ConvertFromByteArray(const uint8_t* aData,
inLength, &outLength);
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)
return NS_ERROR_OUT_OF_MEMORY;
@ -164,7 +164,7 @@ nsScriptableUnicodeConverter::ConvertFromByteArray(const uint8_t* aData,
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
moz_free(buf);
free(buf);
return rv;
}
return NS_ERROR_FAILURE;
@ -193,9 +193,9 @@ nsScriptableUnicodeConverter::ConvertToByteArray(const nsAString& aString,
return rv;
str.Append(data, len);
moz_free(data);
free(data);
// 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)
return NS_ERROR_OUT_OF_MEMORY;
memcpy(*_aData, str.get(), str.Length());
@ -222,7 +222,7 @@ nsScriptableUnicodeConverter::ConvertToInputStream(const nsAString& aString,
rv = inputStream->AdoptData(reinterpret_cast<char*>(data), dataLen);
if (NS_FAILED(rv)) {
moz_free(data);
free(data);
return rv;
}

View File

@ -109,7 +109,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
reply->writeInt32(dataLength);
void* buf = reply->writeInplace(dataLength);
memcpy(buf, data, dataLength);
moz_free(data);
free(data);
} else {
reply->writeInt32(-1);
}
@ -127,7 +127,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
reply->writeInt32(dataLength);
void* buf = reply->writeInplace(dataLength);
memcpy(buf, data, dataLength);
moz_free(data);
free(data);
} else {
reply->writeInt32(-1);
}
@ -153,7 +153,7 @@ status_t BnKeystoreService::onTransact(uint32_t code, const Parcel& data, Parcel
reply->writeInt32(signResultSize);
void* buf = reply->writeInplace(signResultSize);
memcpy(buf, signResult, signResultSize);
moz_free(signResult);
free(signResult);
} else {
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 +
strlen(aName) * 2 + aCaDataLength + aCaDataLength/CA_LINE_SIZE
+ 2;
char *buf = (char *)moz_malloc(bufSize);
char *buf = (char *)malloc(bufSize);
if (!buf) {
*aFormatData = nullptr;
return;
@ -571,7 +571,7 @@ ResponseCode getPublicKey(const char *aKeyName, const uint8_t **aKeyData,
}
size_t bufSize = keyItem->len;
char *buf = (char *)moz_malloc(bufSize);
char *buf = (char *)malloc(bufSize);
if (!buf) {
return SYSTEM_ERROR;
}
@ -647,7 +647,7 @@ ResponseCode signData(const char *aKeyName, const uint8_t *data, size_t length,
return SYSTEM_ERROR;
}
uint8_t *buf = (uint8_t *)moz_malloc(signItem->len);
uint8_t *buf = (uint8_t *)malloc(signItem->len);
if (!buf) {
return SYSTEM_ERROR;
}
@ -1073,7 +1073,7 @@ KeyStore::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
SendResponse(SUCCESS);
SendData(data, (int)dataLength);
moz_free((void *)data);
free((void *)data);
}
ResetHandlerInfo();

View File

@ -190,7 +190,7 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
if(!aMayAllocate) {
return false;
} else {
*aMemory=moz_malloc(aSizeNeeded);
*aMemory=malloc(aSizeNeeded);
if (*aMemory!=nullptr) {
*aSize=aSizeNeeded;
return true;
@ -206,7 +206,7 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
return false;
} else if(aSizeNeeded!=*aSize && aMayAllocate) {
/* we may try to grow or shrink */
void *memory=moz_realloc(*aMemory, aSizeNeeded);
void *memory=realloc(*aMemory, aSizeNeeded);
if(memory!=nullptr) {
*aMemory=memory;
@ -225,11 +225,11 @@ bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t
void nsBidi::Free()
{
moz_free(mDirPropsMemory);
free(mDirPropsMemory);
mDirPropsMemory = nullptr;
moz_free(mLevelsMemory);
free(mLevelsMemory);
mLevelsMemory = nullptr;
moz_free(mRunsMemory);
free(mRunsMemory);
mRunsMemory = nullptr;
}

View File

@ -168,7 +168,7 @@ ComputeDescendantISize(const nsHTMLReflowState& aAncestorReflowState,
for (uint32_t i = len; i-- != 0; ) {
reflowStates[i].~nsHTMLReflowState();
}
moz_free(reflowStates);
free(reflowStates);
return result;
}

View File

@ -50,10 +50,10 @@ GetDataFrom(const T& aObject, uint8_t*& aBuffer, uint32_t& aLength)
{
MOZ_ASSERT(!aBuffer);
aObject.ComputeLengthAndData();
// We use moz_malloc here rather than a FallibleTArray or fallible
// operator new[] since the gfxUserFontEntry will be calling moz_free
// We use malloc here rather than a FallibleTArray or fallible
// operator new[] since the gfxUserFontEntry will be calling free
// on it.
aBuffer = (uint8_t*) moz_malloc(aObject.Length());
aBuffer = (uint8_t*) malloc(aObject.Length());
if (!aBuffer) {
return;
}

View File

@ -21,8 +21,8 @@ create_timecard()
void
destroy_timecard(Timecard *tc)
{
moz_free(tc->entries);
moz_free(tc);
free(tc->entries);
free(tc);
}
void

View File

@ -15,7 +15,7 @@
#define cpr_malloc(a) moz_xmalloc(a)
#define cpr_calloc(a, b) moz_xcalloc(a, b)
#define cpr_realloc(a, b) moz_xrealloc(a, b)
#define cpr_free(a) moz_free(a)
#define cpr_free(a) free(a)
/**

View File

@ -27,8 +27,8 @@ interface nsIStreamLoaderObserver : nsISupports
* If the observer wants to take over responsibility for the
* data buffer (result), it returns NS_SUCCESS_ADOPTED_DATA
* in place of NS_OK as its success code. The loader will then
* "forget" about the data and not moz_free() it after
* onStreamComplete() returns; observer must call moz_free()
* "forget" about the data and not free() it after
* onStreamComplete() returns; observer must call free()
* when the data is no longer required.
*/
void onStreamComplete(in nsIStreamLoader loader,

View File

@ -28,7 +28,7 @@ nsPreloadedStream::nsPreloadedStream(nsIAsyncInputStream *aStream,
nsPreloadedStream::~nsPreloadedStream()
{
moz_free(mBuf);
free(mBuf);
}
NS_IMETHODIMP

View File

@ -103,9 +103,9 @@ nsSocketTransportService::~nsSocketTransportService()
if (mThreadEvent)
PR_DestroyPollableEvent(mThreadEvent);
moz_free(mActiveList);
moz_free(mIdleList);
moz_free(mPollList);
free(mActiveList);
free(mIdleList);
free(mPollList);
gSocketTransportService = nullptr;
}

View File

@ -151,7 +151,7 @@ nsresult
nsCacheMetaData::EnsureBuffer(uint32_t bufSize)
{
if (mBufferSize < bufSize) {
char * buf = (char *)moz_realloc(mBuffer, bufSize);
char * buf = (char *)realloc(mBuffer, bufSize);
if (!buf) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -18,7 +18,7 @@ public:
~nsCacheMetaData() {
mBufferSize = mMetaSize = 0;
moz_free(mBuffer);
free(mBuffer);
mBuffer = nullptr;
}

View File

@ -185,7 +185,7 @@ CacheFileChunk::Read(CacheFileHandle *aHandle, uint32_t aLen,
mState = READING;
if (CanAllocate(aLen)) {
mRWBuf = static_cast<char *>(moz_malloc(aLen));
mRWBuf = static_cast<char *>(malloc(aLen));
if (mRWBuf) {
mRWBufSize = aLen;
ChunkAllocationChanged();
@ -698,7 +698,7 @@ CacheFileChunk::EnsureBufSize(uint32_t aBufSize)
return mStatus;
}
char *newBuf = static_cast<char *>(moz_realloc(mBuf, aBufSize));
char *newBuf = static_cast<char *>(realloc(mBuf, aBufSize));
if (!newBuf) {
SetError(NS_ERROR_OUT_OF_MEMORY);
return mStatus;

View File

@ -287,8 +287,8 @@ AddrInfo::~AddrInfo()
while ((addrElement = mAddresses.popLast())) {
delete addrElement;
}
moz_free(mHostName);
moz_free(mCanonicalName);
free(mHostName);
free(mCanonicalName);
}
void

View File

@ -24,7 +24,7 @@ SpdyZlibReporter::Alloc(void*, uInt items, uInt size)
SpdyZlibReporter::Free(void*, void* p)
{
sAmount -= MallocSizeOfOnFree(p);
moz_free(p);
free(p);
}
NS_IMETHODIMP

View File

@ -1170,8 +1170,8 @@ WebSocketChannel::~WebSocketChannel()
MOZ_ASSERT(!mCancelable, "DNS/Proxy Request still alive at destruction");
MOZ_ASSERT(!mConnecting, "Should not be connecting in destructor");
moz_free(mBuffer);
moz_free(mDynamicOutput);
free(mBuffer);
free(mDynamicOutput);
delete mCurrentOut;
while ((mCurrentOut = (OutboundMessage *) mOutgoingPingMessages.PopFront()))
@ -1400,7 +1400,7 @@ WebSocketChannel::UpdateReadBuffer(uint8_t *buffer, uint32_t count,
mBufferSize += count + 8192 + mBufferSize/3;
LOG(("WebSocketChannel: update read buffer extended to %u\n", mBufferSize));
uint8_t *old = mBuffer;
mBuffer = (uint8_t *)moz_realloc(mBuffer, mBufferSize);
mBuffer = (uint8_t *)realloc(mBuffer, mBufferSize);
if (!mBuffer) {
mBuffer = old;
return false;
@ -1777,7 +1777,7 @@ WebSocketChannel::ProcessInput(uint8_t *buffer, uint32_t count)
// release memory if we've been processing a large message
if (mBufferSize > kIncomingBufferStableSize) {
mBufferSize = kIncomingBufferStableSize;
moz_free(mBuffer);
free(mBuffer);
mBuffer = (uint8_t *)moz_xmalloc(mBufferSize);
}
}

View File

@ -1008,7 +1008,7 @@ DataChannelConnection::SendOpenRequestMessage(const nsACString& label,
break;
default:
// FIX! need to set errno! Or make all these SendXxxx() funcs return 0 or errno!
moz_free(req);
free(req);
return (0);
}
if (unordered) {
@ -1025,7 +1025,7 @@ DataChannelConnection::SendOpenRequestMessage(const nsACString& label,
int32_t result = SendControlMessage(req, req_size, stream);
moz_free(req);
free(req);
return result;
}
@ -1731,7 +1731,7 @@ DataChannelConnection::SendOutgoingStreamReset()
} else {
mStreamsResetting.Clear();
}
moz_free(srs);
free(srs);
}
void

View File

@ -83,7 +83,7 @@ public:
~QueuedDataMessage()
{
moz_free(mData);
free(mData);
}
uint16_t mStream;

View File

@ -442,8 +442,8 @@ nsBinHexDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt)
NS_ENSURE_TRUE(mNextListener, NS_ERROR_FAILURE);
mDataBuffer = (char *) moz_malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
mOutgoingBuffer = (char *) moz_malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
mDataBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
mOutgoingBuffer = (char *) malloc((sizeof(char) * nsIOService::gDefaultSegmentSize));
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...

View File

@ -151,20 +151,20 @@ nsHTTPCompressConv::OnDataAvailable(nsIRequest* request,
if (mInpBuffer != nullptr && streamLen > mInpBufferLen)
{
mInpBuffer = (unsigned char *) moz_realloc(mInpBuffer, mInpBufferLen = streamLen);
mInpBuffer = (unsigned char *) realloc(mInpBuffer, mInpBufferLen = streamLen);
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)
return NS_ERROR_OUT_OF_MEMORY;
}
if (mInpBuffer == nullptr)
mInpBuffer = (unsigned char *) moz_malloc(mInpBufferLen = streamLen);
mInpBuffer = (unsigned char *) malloc(mInpBufferLen = streamLen);
if (mOutBuffer == nullptr)
mOutBuffer = (unsigned char *) moz_malloc(mOutBufferLen = streamLen * 3);
mOutBuffer = (unsigned char *) malloc(mOutBufferLen = streamLen * 3);
if (mInpBuffer == nullptr || mOutBuffer == nullptr)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -480,7 +480,7 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
{
(void *(*)(size_t))moz_xmalloc,
(void *(*)(void *, size_t))moz_xrealloc,
moz_free
free
};
static const char16_t kExpatSeparator[] = { 0xFFFF, '\0' };

View File

@ -343,7 +343,7 @@ RDFContentSinkImpl::~RDFContentSinkImpl()
delete mContextStack;
}
moz_free(mText);
free(mText);
if (--gRefCnt == 0) {
@ -755,7 +755,7 @@ RDFContentSinkImpl::AddText(const char16_t* aText, int32_t aLength)
{
// Create buffer when we first need it
if (0 == mTextSize) {
mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096);
mText = (char16_t *) malloc(sizeof(char16_t) * 4096);
if (!mText) {
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)) ?
(2 * mTextSize) : (mTextSize + aLength);
char16_t* newText =
(char16_t *) moz_realloc(mText, sizeof(char16_t) * newSize);
(char16_t *) realloc(mText, sizeof(char16_t) * newSize);
if (!newText)
return NS_ERROR_OUT_OF_MEMORY;
mTextSize = newSize;

View File

@ -609,7 +609,7 @@ nsHTTPListener::~nsHTTPListener()
send_done_signal();
if (mResultData) {
moz_free(const_cast<uint8_t *>(mResultData));
free(const_cast<uint8_t *>(mResultData));
}
if (mLoader) {

View File

@ -402,10 +402,10 @@ namespace {
// 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.
//
// Note: the wrappers for moz_malloc, moz_realloc and moz_malloc_usable_size
// are necessary because the sqlite_mem_methods type signatures differ slightly
// Note: the wrappers for malloc, realloc and moz_malloc_usable_size are
// 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
// a wrapper for moz_free.
// a wrapper for free.
#ifdef MOZ_DMD
@ -429,7 +429,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(SqliteMallocSizeOfOnFree)
static void *sqliteMemMalloc(int n)
{
void* p = ::moz_malloc(n);
void* p = ::malloc(n);
#ifdef MOZ_DMD
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
#endif
@ -441,14 +441,14 @@ static void sqliteMemFree(void *p)
#ifdef MOZ_DMD
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
#endif
::moz_free(p);
::free(p);
}
static void *sqliteMemRealloc(void *p, int n)
{
#ifdef MOZ_DMD
gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p);
void *pnew = ::moz_realloc(p, n);
void *pnew = ::realloc(p, n);
if (pnew) {
gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(pnew);
} else {
@ -457,7 +457,7 @@ static void *sqliteMemRealloc(void *p, int n)
}
return pnew;
#else
return ::moz_realloc(p, n);
return ::realloc(p, n);
#endif
}

View File

@ -218,7 +218,7 @@ NS_Realloc(void* aPtr, size_t aSize)
XPCOM_API(void)
NS_Free(void* aPtr)
{
moz_free(aPtr);
free(aPtr);
}
nsresult

View File

@ -167,13 +167,13 @@ struct nsTArrayInfallibleAllocatorBase
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)
{
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) {}
};
@ -185,7 +185,7 @@ struct nsTArrayInfallibleAllocator : nsTArrayInfallibleAllocatorBase
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); }
};

View File

@ -228,7 +228,7 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString)
if (length <= 64) {
copy = temp;
} else {
copy = reinterpret_cast<char16_t*>(moz_malloc(byteCount));
copy = reinterpret_cast<char16_t*>(malloc(byteCount));
if (!copy) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -237,7 +237,7 @@ nsBinaryOutputStream::WriteWStringZ(const char16_t* aString)
mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
if (copy != temp) {
moz_free(copy);
free(copy);
}
#endif
@ -798,18 +798,18 @@ nsBinaryInputStream::ReadBytes(uint32_t aLength, char** aResult)
uint32_t bytesRead;
char* s;
s = reinterpret_cast<char*>(moz_malloc(aLength));
s = reinterpret_cast<char*>(malloc(aLength));
if (!s) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = Read(s, aLength, &bytesRead);
if (NS_FAILED(rv)) {
moz_free(s);
free(s);
return rv;
}
if (bytesRead != aLength) {
moz_free(s);
free(s);
return NS_ERROR_FAILURE;
}

View File

@ -1745,7 +1745,7 @@ nsLocalFile::GetVersionInfoField(const char* aField, nsAString& aResult)
}
}
}
moz_free(ver);
free(ver);
return rv;
}

View File

@ -58,7 +58,7 @@ nsScriptableInputStream::Read(uint32_t aCount, char** aResult)
// bug716556 - Ensure count+1 doesn't overflow
uint32_t count =
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) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -64,7 +64,7 @@ nsSegmentedBuffer::AppendNewSegment()
mSegmentArrayCount = newArraySize;
}
char* seg = (char*)moz_malloc(mSegmentSize);
char* seg = (char*)malloc(mSegmentSize);
if (!seg) {
return nullptr;
}
@ -77,7 +77,7 @@ bool
nsSegmentedBuffer::DeleteFirstSegment()
{
NS_ASSERTION(mSegmentArray[mFirstSegmentIndex] != nullptr, "deleting bad segment");
moz_free(mSegmentArray[mFirstSegmentIndex]);
free(mSegmentArray[mFirstSegmentIndex]);
mSegmentArray[mFirstSegmentIndex] = nullptr;
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
if (mFirstSegmentIndex == last) {
@ -94,7 +94,7 @@ nsSegmentedBuffer::DeleteLastSegment()
{
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
NS_ASSERTION(mSegmentArray[last] != nullptr, "deleting bad segment");
moz_free(mSegmentArray[last]);
free(mSegmentArray[last]);
mSegmentArray[last] = nullptr;
mLastSegmentIndex = last;
return (bool)(mLastSegmentIndex == mFirstSegmentIndex);
@ -105,7 +105,7 @@ nsSegmentedBuffer::ReallocLastSegment(size_t aNewSize)
{
int32_t last = ModSegArraySize(mLastSegmentIndex - 1);
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) {
mSegmentArray[last] = newSegment;
return true;
@ -119,7 +119,7 @@ nsSegmentedBuffer::Empty()
if (mSegmentArray) {
for (uint32_t i = 0; i < mSegmentArrayCount; i++) {
if (mSegmentArray[i]) {
moz_free(mSegmentArray[i]);
free(mSegmentArray[i]);
}
}
nsMemory::Free(mSegmentArray);

View File

@ -31,8 +31,8 @@ if CONFIG['_MSC_VER']:
CFLAGS += ['-Zl']
# 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
# 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