Bug 1138293 - Use malloc/free/realloc/calloc instead of moz_malloc/moz_free/moz_realloc/moz_calloc. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 19 Feb 2015 13:51:06 +0900
changeset 255619 b5d54a547bdca5d76cb338d430829caaeadeb2aa
parent 255618 559aa82a7cdc8d7d15d54d030bb94ea1038ac3fd
child 255620 f2c533ee40718490384c20439e517d7a44b7523d
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1138293
milestone40.0a1
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.
dom/base/BlobSet.h
dom/base/File.h
dom/base/nsAttrAndChildArray.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDOMFileReader.cpp
dom/base/nsDOMFileReader.h
dom/base/nsScriptLoader.cpp
dom/base/nsTextFragment.cpp
dom/canvas/WebGLContextBuffers.cpp
dom/fetch/Fetch.cpp
dom/indexedDB/ActorsParent.cpp
dom/ipc/Blob.cpp
dom/media/EncodedBufferCache.cpp
dom/media/webaudio/AnalyserNode.cpp
dom/media/webrtc/AudioOutputObserver.h
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
dom/media/webrtc/MediaEngineWebRTCAudio.cpp
dom/plugins/ipc/PluginInterposeOSX.mm
dom/xul/nsXULContentSink.cpp
gfx/2d/Tools.h
gfx/graphite2/src/MozGrMalloc.h
gfx/skia/patches/archive/0017-Bug-740194-SkMemory-mozalloc.patch
gfx/skia/trunk/src/ports/SkMemory_mozalloc.cpp
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxImageSurface.cpp
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxTextRun.h
gfx/thebes/gfxUserFontSet.cpp
image/decoders/nsBMPDecoder.cpp
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsICODecoder.cpp
image/decoders/nsPNGDecoder.cpp
image/encoders/bmp/nsBMPEncoder.cpp
image/encoders/ico/nsICOEncoder.cpp
image/encoders/jpeg/nsJPEGEncoder.cpp
image/encoders/png/nsPNGEncoder.cpp
image/src/imgFrame.cpp
intl/hyphenation/hnjalloc.h
intl/locale/mac/nsCollationMacUC.cpp
intl/uconv/nsScriptableUConv.cpp
ipc/keystore/KeyStore.cpp
layout/base/nsBidi.cpp
layout/generic/nsFontInflationData.cpp
layout/style/FontFace.cpp
media/webrtc/signaling/src/common/time_profiling/timecard.c
media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
netwerk/base/nsIStreamLoader.idl
netwerk/base/nsPreloadedStream.cpp
netwerk/base/nsSocketTransportService2.cpp
netwerk/cache/nsCacheMetaData.cpp
netwerk/cache/nsCacheMetaData.h
netwerk/cache2/CacheFileChunk.cpp
netwerk/dns/DNS.cpp
netwerk/protocol/http/SpdyZlibReporter.cpp
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/datachannel/DataChannel.h
netwerk/streamconv/converters/nsBinHexDecoder.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
parser/html/nsHtml5StreamParser.cpp
rdf/base/nsRDFContentSink.cpp
security/manager/ssl/src/nsNSSCallbacks.cpp
storage/src/mozStorageService.cpp
xpcom/base/nsMemoryImpl.cpp
xpcom/glue/nsTArray.h
xpcom/io/nsBinaryStream.cpp
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsScriptableInputStream.cpp
xpcom/io/nsSegmentedBuffer.cpp
xpcom/typelib/xpt/moz.build
--- a/dom/base/BlobSet.h
+++ b/dom/base/BlobSet.h
@@ -15,17 +15,17 @@ namespace dom {
 class BlobSet {
 public:
   BlobSet()
     : mData(nullptr), mDataLen(0), mDataBufferLen(0)
   {}
 
   ~BlobSet()
   {
-    moz_free(mData);
+    free(mData);
   }
 
   nsresult AppendVoidPtr(const void* aData, uint32_t aLength);
   nsresult AppendString(const nsAString& aString, bool nativeEOL, JSContext* aCx);
   nsresult AppendBlobImpl(FileImpl* aBlobImpl);
   nsresult AppendBlobImpls(const nsTArray<nsRefPtr<FileImpl>>& aBlobImpls);
 
   nsTArray<nsRefPtr<FileImpl>>& GetBlobImpls() { Flush(); return mBlobImpls; }
@@ -47,17 +47,17 @@ protected:
     CheckedUint32 bufferLen =
       std::max<uint32_t>(static_cast<uint32_t>(mDataBufferLen), 1);
     while (bufferLen.isValid() && bufferLen.value() < mDataLen + aSize)
       bufferLen *= 2;
 
     if (!bufferLen.isValid())
       return false;
 
-    void* data = moz_realloc(mData, bufferLen.value());
+    void* data = realloc(mData, bufferLen.value());
     if (!data)
       return false;
 
     mData = data;
     mDataBufferLen = bufferLen.value();
     mDataLen += aSize;
     return true;
   }
--- a/dom/base/File.h
+++ b/dom/base/File.h
@@ -79,25 +79,25 @@ public:
   Create(nsISupports* aParent, const nsAString& aContentType,
          uint64_t aLength);
 
   static already_AddRefed<File>
   Create(nsISupports* aParent, const nsAString& aContentType, uint64_t aStart,
          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,
                    const nsAString& aName, const nsAString& aContentType,
                    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,
                    const nsAString& aContentType);
 
   static already_AddRefed<File>
   CreateTemporaryFileBlob(nsISupports* aParent, PRFileDesc* aFD,
                           uint64_t aStartPos, uint64_t aLength,
@@ -547,17 +547,17 @@ public:
       mozilla::StaticMutexAutoLock lock(sDataOwnerMutex);
 
       remove();
       if (sDataOwners->isEmpty()) {
         // Free the linked list if it's empty.
         sDataOwners = nullptr;
       }
 
-      moz_free(mData);
+      free(mData);
     }
 
   public:
     static void EnsureMemoryReporterRegistered();
 
     // sDataOwners and sMemoryReporterRegistered may only be accessed while
     // holding sDataOwnerMutex!  You also must hold the mutex while touching
     // elements of the linked list that DataOwner inherits from.
--- a/dom/base/nsAttrAndChildArray.cpp
+++ b/dom/base/nsAttrAndChildArray.cpp
@@ -97,17 +97,17 @@ nsAttrAndChildArray::nsAttrAndChildArray
 nsAttrAndChildArray::~nsAttrAndChildArray()
 {
   if (!mImpl) {
     return;
   }
 
   Clear();
 
-  moz_free(mImpl);
+  free(mImpl);
 }
 
 nsIContent*
 nsAttrAndChildArray::GetSafeChildAt(uint32_t aPos) const
 {
   if (aPos < ChildCount()) {
     return ChildAt(aPos);
   }
@@ -630,21 +630,21 @@ nsAttrAndChildArray::Compact()
             mImpl->mBuffer + slotCount * ATTRSIZE,
             childCount * sizeof(nsIContent*));
     SetAttrSlotCount(attrCount);
   }
 
   // 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;
   }
 }
 
 void
 nsAttrAndChildArray::Clear()
@@ -771,17 +771,17 @@ nsAttrAndChildArray::GrowBy(uint32_t aGr
       size += ATTRCHILD_ARRAY_GROWSIZE;
     } while (size < minSize);
   }
   else {
     size = 1u << mozilla::CeilingLog2(minSize);
   }
 
   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;
 
   // Set initial counts if we didn't have a buffer before
   if (needToInitialize) {
     mImpl->mMappedAttrs = nullptr;
     SetAttrSlotAndChildCount(0, 0);
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6047,17 +6047,17 @@ nsContentUtils::CreateArrayBuffer(JSCont
 // TODO: bug 704447: large file support
 nsresult
 nsContentUtils::CreateBlobBuffer(JSContext* aCx,
                                  nsISupports* aParent,
                                  const nsACString& aData,
                                  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);
     blob = mozilla::dom::File::CreateMemoryFile(aParent, blobData, blobLen,
                                                 EmptyString());
   } else {
     return NS_ERROR_OUT_OF_MEMORY;
   }
--- a/dom/base/nsDOMFileReader.cpp
+++ b/dom/base/nsDOMFileReader.cpp
@@ -358,17 +358,17 @@ nsDOMFileReader::DoReadData(nsIAsyncInpu
   }
   else {
     //Update memory buffer to reflect the contents of the file
     if (mDataLen + aCount > UINT32_MAX) {
       // PR_Realloc doesn't support over 4GB memory size even if 64-bit OS
       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);
     }
 
     uint32_t bytesRead = 0;
     aStream->Read(mFileData + mDataLen, aCount, &bytesRead);
     NS_ASSERTION(bytesRead == aCount, "failed to read data");
   }
 
--- a/dom/base/nsDOMFileReader.h
+++ b/dom/base/nsDOMFileReader.h
@@ -126,17 +126,17 @@ protected:
   void ReadFileContent(File& aBlob,
                        const nsAString &aCharset, eDataFormat aDataFormat,
                        ErrorResult& aRv);
   nsresult GetAsText(nsIDOMBlob *aFile, const nsACString &aCharset,
                      const char *aFileData, uint32_t aDataLen, nsAString &aResult);
   nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, uint32_t aDataLen, nsAString &aResult);
 
   void FreeFileData() {
-    moz_free(mFileData);
+    free(mFileData);
     mFileData = nullptr;
     mDataLen = 0;
   }
 
   char *mFileData;
   nsCOMPtr<nsIDOMBlob> mFile;
   nsCString mCharset;
   uint32_t mDataLen;
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -1456,17 +1456,17 @@ nsScriptLoader::OnStreamComplete(nsIStre
       UnblockParser(request);
       FireScriptAvailable(rv, request);
       ContinueParserAsync(request);
     } else {
       mPreloads.RemoveElement(request, PreloadRequestComparator());
     }
     rv = NS_OK;
   } else {
-    moz_free(const_cast<uint8_t *>(aString));
+    free(const_cast<uint8_t *>(aString));
     rv = NS_SUCCESS_ADOPTED_DATA;
   }
 
   // Process our request and/or any pending ones
   ProcessPendingRequests();
 
   return rv;
 }
--- a/dom/base/nsTextFragment.cpp
+++ b/dom/base/nsTextFragment.cpp
@@ -79,17 +79,17 @@ nsTextFragment::~nsTextFragment()
   ReleaseText();
   MOZ_COUNT_DTOR(nsTextFragment);
 }
 
 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;
   mState.mIsBidi = false;
 
   // Set mState.mIs2b, mState.mInHeap, and mState.mLength = 0 with mAllBits;
   mAllBits = 0;
 }
@@ -102,17 +102,17 @@ nsTextFragment::operator=(const nsTextFr
   if (aOther.mState.mLength) {
     if (!aOther.mState.mInHeap) {
       m1b = aOther.m1b; // This will work even if aOther is using m2b
     }
     else {
       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 {
         // allocate a buffer for a single REPLACEMENT CHARACTER
         m2b = static_cast<char16_t*>(moz_xmalloc(sizeof(char16_t)));
         m2b[0] = 0xFFFD; // REPLACEMENT CHARACTER
         mState.mIs2b = true;
         mState.mInHeap = true;
@@ -250,30 +250,30 @@ nsTextFragment::SetTo(const char16_t* aB
   }
 
   // See if we need to store the data in ucs2 or not
   int32_t first16bit = FirstNon8Bit(ucp, uend);
 
   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;
     }
     memcpy(m2b, aBuffer, m2bSize);
 
     mState.mIs2b = true;
     if (aUpdateBidi) {
       UpdateBidiFlag(aBuffer + first16bit, aLength - first16bit);
     }
 
   } 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;
     }
 
     // Copy data
     LossyConvertEncoding16to8 converter(buff);
     copy_string(aBuffer, aBuffer+aLength, converter);
     m1b = buff;
@@ -321,17 +321,17 @@ nsTextFragment::Append(const char16_t* a
   if (mState.mLength == 0) {
     return SetTo(aBuffer, aLength, aUpdateBidi);
   }
 
   // Should we optimize for aData.Length() == 0?
 
   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;
     }
 
     memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(char16_t));
     mState.mLength += aLength;
     m2b = buff;
 
@@ -343,55 +343,55 @@ nsTextFragment::Append(const char16_t* a
   }
 
   // Current string is a 1-byte string, check if the new data fits in one byte too.
   int32_t first16bit = FirstNon8Bit(aBuffer, aBuffer + aLength);
 
   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;
     }
 
     // Copy data into buff
     LossyConvertEncoding8to16 converter(buff);
     copy_string(m1b, m1b+mState.mLength, converter);
 
     memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(char16_t));
     mState.mLength += aLength;
     mState.mIs2b = true;
 
     if (mState.mInHeap) {
-      moz_free(m2b);
+      free(m2b);
     }
     m2b = buff;
 
     mState.mInHeap = true;
 
     if (aUpdateBidi) {
       UpdateBidiFlag(aBuffer + first16bit, aLength - first16bit);
     }
 
     return true;
   }
 
   // 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;
     }
 
     memcpy(buff, m1b, mState.mLength);
     mState.mInHeap = true;
   }
 
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -169,17 +169,17 @@ WebGLContext::BufferData(GLenum target, 
     if (!CheckedInt<GLsizeiptr>(size).isValid())
         return ErrorOutOfMemory("bufferData: bad size");
 
     WebGLBuffer* boundBuffer = bufferSlot.get();
 
     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");
 
     MakeContextCurrent();
     InvalidateBufferFetching();
 
     GLenum error = CheckedBufferData(target, size, zeroBuffer.get(), usage);
 
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -669,17 +669,17 @@ class MOZ_STACK_CLASS AutoFreeBuffer fin
 
 public:
   explicit AutoFreeBuffer(uint8_t* aBuffer)
     : mBuffer(aBuffer)
   {}
 
   ~AutoFreeBuffer()
   {
-    moz_free(mBuffer);
+    free(mBuffer);
   }
 
   void
   Reset()
   {
     mBuffer= nullptr;
   }
 };
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -14780,40 +14780,40 @@ ObjectStoreAddOrPutRequestOp::DoDatabase
 
   key.BindToStatement(stmt, NS_LITERAL_CSTRING("key_value"));
 
   // Compress the bytes before adding into the database.
   const char* uncompressed =
     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;
     }
 
     snappy::RawCompress(uncompressed, uncompressedLength, compressed,
                         &compressedLength);
 
     uint8_t* dataBuffer = reinterpret_cast<uint8_t*>(compressed);
     size_t dataBufferLength = compressedLength;
 
     // If this call succeeds, | compressed | is now owned by the statement, and
     // we are no longer responsible for it.
     rv = stmt->BindAdoptedBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
                                      dataBufferLength);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      moz_free(compressed);
+      free(compressed);
       return rv;
     }
   }
 
   nsCOMPtr<nsIFile> fileDirectory;
   nsCOMPtr<nsIFile> journalDirectory;
 
   if (mFileManager) {
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -831,17 +831,17 @@ CreateBlobImpl(const nsTArray<uint8_t>& 
       sizeof(aMemoryData[0]) / sizeof(char);
 
     if (!aMetadata.mHasRecursed &&
         NS_WARN_IF(aMetadata.mLength != uint64_t(length))) {
       ASSERT_UNLESS_FUZZING();
       return nullptr;
     }
 
-    void* buffer = moz_malloc(length * elementSizeMultiplier);
+    void* buffer = malloc(length * elementSizeMultiplier);
     if (NS_WARN_IF(!buffer)) {
       return nullptr;
     }
 
     memcpy(buffer, aMemoryData.Elements(), length * elementSizeMultiplier);
 
     if (!aMetadata.mHasRecursed && aMetadata.IsFile()) {
       blobImpl =
--- a/dom/media/EncodedBufferCache.cpp
+++ b/dom/media/EncodedBufferCache.cpp
@@ -49,17 +49,17 @@ EncodedBufferCache::ExtractBlob(nsISuppo
     // generate new temporary file to write
     blob = dom::File::CreateTemporaryFileBlob(aParent, mFD, 0, mDataSize,
                                               aContentType);
     // fallback to memory blob
     mTempFileEnabled = false;
     mDataSize = 0;
     mFD = nullptr;
   } else {
-    void* blobData = moz_malloc(mDataSize);
+    void* blobData = malloc(mDataSize);
     NS_ASSERTION(blobData, "out of memory!!");
 
     if (blobData) {
       for (uint32_t i = 0, offset = 0; i < mEncodedBuffers.Length(); i++) {
         memcpy((uint8_t*)blobData + offset, mEncodedBuffers.ElementAt(i).Elements(),
                mEncodedBuffers.ElementAt(i).Length());
         offset += mEncodedBuffers.ElementAt(i).Length();
       }
--- a/dom/media/webaudio/AnalyserNode.cpp
+++ b/dom/media/webaudio/AnalyserNode.cpp
@@ -250,17 +250,17 @@ AnalyserNode::GetByteTimeDomainData(cons
 bool
 AnalyserNode::FFTAnalysis()
 {
   float* inputBuffer;
   bool allocated = false;
   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;
     }
     memcpy(inputBuffer, mBuffer.Elements() + mWriteIndex, sizeof(float) * (FftSize() - mWriteIndex));
     memcpy(inputBuffer + FftSize() - mWriteIndex, mBuffer.Elements(), sizeof(float) * mWriteIndex);
     allocated = true;
   }
 
@@ -275,17 +275,17 @@ AnalyserNode::FFTAnalysis()
     double scalarMagnitude = NS_hypot(mAnalysisBlock.RealData(i),
                                       mAnalysisBlock.ImagData(i)) *
                              magnitudeScale;
     mOutputBuffer[i] = mSmoothingTimeConstant * mOutputBuffer[i] +
                        (1.0 - mSmoothingTimeConstant) * scalarMagnitude;
   }
 
   if (allocated) {
-    moz_free(inputBuffer);
+    free(inputBuffer);
   }
   return true;
 }
 
 void
 AnalyserNode::ApplyBlackmanWindow(float* aBuffer, uint32_t aSize)
 {
   double alpha = 0.16;
--- a/dom/media/webrtc/AudioOutputObserver.h
+++ b/dom/media/webrtc/AudioOutputObserver.h
@@ -47,17 +47,17 @@ private:
   virtual ~AudioOutputObserver();
   uint32_t mPlayoutFreq;
   uint32_t mPlayoutChannels;
 
   nsAutoPtr<webrtc::SingleRwFifo> mPlayoutFifo;
   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;
 };
 
 extern StaticRefPtr<AudioOutputObserver> gFarendObserver;
 
 }
 
 #endif
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -598,17 +598,17 @@ MediaEngineGonkVideoSource::OnTakePictur
   public:
     GenerateBlobRunnable(nsTArray<nsRefPtr<PhotoCallback>>& aCallbacks,
                          uint8_t* aData,
                          uint32_t aLength,
                          const nsAString& aMimeType)
       : mPhotoDataLength(aLength)
     {
       mCallbacks.SwapElements(aCallbacks);
-      mPhotoData = (uint8_t*) moz_malloc(aLength);
+      mPhotoData = (uint8_t*) malloc(aLength);
       memcpy(mPhotoData, aData, mPhotoDataLength);
       mMimeType = aMimeType;
     }
 
     NS_IMETHOD Run()
     {
       nsRefPtr<dom::File> blob =
         dom::File::CreateMemoryFile(nullptr, mPhotoData, mPhotoDataLength, mMimeType);
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -62,25 +62,25 @@ AudioOutputObserver::AudioOutputObserver
 {
   // Buffers of 10ms chunks
   mPlayoutFifo = new webrtc::SingleRwFifo(MAX_AEC_FIFO_DEPTH/10);
 }
 
 AudioOutputObserver::~AudioOutputObserver()
 {
   Clear();
-  moz_free(mSaved);
+  free(mSaved);
   mSaved = nullptr;
 }
 
 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
 }
 
 FarEndAudioChunk *
 AudioOutputObserver::Pop()
 {
   return (FarEndAudioChunk *) mPlayoutFifo->Pop();
@@ -539,30 +539,30 @@ MediaEngineWebRTCAudioSource::Process(in
   int length, int samplingFreq, bool isStereo)
 {
   // On initial capture, throw away all far-end data except the most recent sample
   // since it's already irrelevant and we want to keep avoid confusing the AEC far-end
   // input code with "old" audio.
   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
     }
   }
 
   while (gFarendObserver->Size() > 0) {
     FarEndAudioChunk *buffer = gFarendObserver->Pop(); // only call if size() > 0
     if (buffer) {
       int length = buffer->mSamples;
       int res = mVoERender->ExternalPlayoutData(buffer->mData,
                                                 gFarendObserver->PlayoutFrequency(),
                                                 gFarendObserver->PlayoutChannels(),
                                                 mPlayoutDelay,
                                                 length);
-      moz_free(buffer);
+      free(buffer);
       if (res == -1) {
         return;
       }
     }
   }
 
   MonitorAutoLock lock(mMonitor);
   if (mState != kStarted)
--- a/dom/plugins/ipc/PluginInterposeOSX.mm
+++ b/dom/plugins/ipc/PluginInterposeOSX.mm
@@ -260,23 +260,23 @@ NSCursorInfo::NSCursorInfo(const Cursor*
           ::CGImageRelease(image);
         }
         ::CGContextRelease(context);
       }
       ::CGColorSpaceRelease(color);
     }
   }
 
-  moz_free(bitmap);
+  free(bitmap);
 }
 
 NSCursorInfo::~NSCursorInfo()
 {
   if (mCustomImageData) {
-    moz_free(mCustomImageData);
+    free(mCustomImageData);
   }
 }
 
 NSCursor* NSCursorInfo::GetNSCursor() const
 {
   NSCursor* retval = nil;
 
   Class nsCursorClass = [NSCursor class];
@@ -433,17 +433,17 @@ NSCursor* NSCursorInfo::GetTransparentCu
         retval =
           [[[NSCursor alloc] initWithImage:image
                                    hotSpot:NSMakePoint(mHotSpot.x, mHotSpot.y)]
            autorelease];
       }
     }
   }
 
-  moz_free(data);
+  free(data);
 
   // Fall back to an arrow cursor if (for some reason) the above code failed.
   if (!retval) {
     retval = [NSCursor arrowCursor];
   }
 
   return retval;
 }
@@ -523,17 +523,17 @@ void NSCursorInfo::SetType(Type aType)
 void NSCursorInfo::SetHotSpot(nsPoint aHotSpot)
 {
   mHotSpot = 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);
     memcpy(mCustomImageData, aData, aDataLength);
   } else {
     mCustomImageData = NULL;
   }
   mCustomImageDataLength = aDataLength;
--- a/dom/xul/nsXULContentSink.cpp
+++ b/dom/xul/nsXULContentSink.cpp
@@ -179,17 +179,17 @@ XULContentSinkImpl::XULContentSinkImpl()
 XULContentSinkImpl::~XULContentSinkImpl()
 {
     NS_IF_RELEASE(mParser); // XXX should've been released by now, unless error.
 
     // The context stack _should_ be empty, unless something has gone wrong.
     NS_ASSERTION(mContextStack.Depth() == 0, "Context stack not empty?");
     mContextStack.Clear();
 
-    moz_free(mText);
+    free(mText);
 }
 
 //----------------------------------------------------------------------
 // nsISupports interface
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(XULContentSinkImpl)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XULContentSinkImpl)
@@ -1046,17 +1046,17 @@ XULContentSinkImpl::AddAttributes(const 
 }
 
 nsresult
 XULContentSinkImpl::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 (nullptr == mText) {
           return NS_ERROR_OUT_OF_MEMORY;
       }
       mTextSize = 4096;
   }
 
   // Copy data from string into our buffer; flush buffer when it fills up
   int32_t offset = 0;
@@ -1069,17 +1069,17 @@ XULContentSinkImpl::AddText(const char16
       if (mConstrainSize) {
         nsresult rv = FlushText();
         if (NS_OK != rv) {
             return rv;
         }
       }
       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;
         }
       }
     }
     memcpy(&mText[mTextLength],aText + offset, sizeof(char16_t) * amount);
     
     mTextLength += amount;
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -129,40 +129,40 @@ struct AlignedArray
       // Since we used the placement |operator new| function to construct the
       // elements of this array we need to invoke their destructors manually.
       // For types where the destructor does nothing the compiler's dead code
       // elimination step should optimize this loop away.
       mPtr[i].~T();
     }
 #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()) {
       mStorage = nullptr;
       mPtr = nullptr;
       mCount = 0;
       return;
     }
     // We don't create an array of T here, since we don't want ctors to be
     // invoked at the wrong places if we realign below.
     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;
       mPtr = nullptr;
       mCount = 0;
       return;
     }
     if (uintptr_t(mStorage) % alignment) {
--- a/gfx/graphite2/src/MozGrMalloc.h
+++ b/gfx/graphite2/src/MozGrMalloc.h
@@ -1,20 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 #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.
 
 #include "mozilla/mozalloc.h"
 
 #define malloc moz_xmalloc
 #define calloc moz_xcalloc
 #define realloc moz_xrealloc
-#define free moz_free
 
 #endif // MOZ_GR_MALLOC_H
--- a/gfx/skia/patches/archive/0017-Bug-740194-SkMemory-mozalloc.patch
+++ b/gfx/skia/patches/archive/0017-Bug-740194-SkMemory-mozalloc.patch
@@ -59,15 +59,15 @@ index 0000000..1f16ee5
 +    return sk_malloc_flags(size, SK_MALLOC_THROW);
 +}
 +
 +void* sk_realloc_throw(void* addr, size_t size) {
 +    return moz_xrealloc(addr, 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);
 +}
 +
--- a/gfx/skia/trunk/src/ports/SkMemory_mozalloc.cpp
+++ b/gfx/skia/trunk/src/ports/SkMemory_mozalloc.cpp
@@ -26,22 +26,22 @@ void* sk_malloc_throw(size_t size) {
     return sk_malloc_flags(size, SK_MALLOC_THROW);
 }
 
 void* sk_realloc_throw(void* addr, size_t size) {
     return moz_xrealloc(addr, 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) {
     return moz_xcalloc(size, 1);
 }
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -102,17 +102,17 @@ public:
         // here would be memory allocation, in which case mFace remains null.
         if (aFontEntry->mFilename[0] != '/') {
             nsRefPtr<nsZipArchive> reader =
                 Omnijar::GetReader(Omnijar::Type::GRE);
             nsZipItem *item = reader->GetItem(aFontEntry->mFilename.get());
             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);
                 NS_ASSERTION(bufSize == item->RealSize(),
                              "error reading bundled font");
 
                 if (FT_Err_Ok != FT_New_Memory_Face(ft, mFontDataBuf, bufSize,
                                                     aFontEntry->mFTFontIndex,
@@ -131,17 +131,17 @@ public:
         }
         mOwnsFace = true;
     }
 
     ~AutoFTFace() {
         if (mFace && mOwnsFace) {
             FT_Done_Face(mFace);
             if (mFontDataBuf) {
-                moz_free(mFontDataBuf);
+                free(mFontDataBuf);
             }
         }
     }
 
     operator FT_Face() { return mFace; }
 
     // If we 'forget' the FT_Face (used when ownership is handed over to Cairo),
     // we do -not- free the mFontDataBuf (if used); that also becomes the
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -1147,17 +1147,17 @@ public:
         NS_ASSERTION(aLength <= gfxPlatform::GetPlatform()->WordCacheCharLimit(),
                      "excessive length for gfxShapedWord!");
 
         // Compute size needed including the mCharacterGlyphs array
         // and a copy of the original text
         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;
         }
 
         // Construct in the pre-allocated storage, using placement new
         return new (storage) gfxShapedWord(aText, aLength, aRunScript,
                                            aAppUnitsPerDevUnit, aFlags);
     }
@@ -1178,29 +1178,29 @@ public:
                                     narrowText);
             return Create((const uint8_t*)(narrowText.BeginReading()),
                           aLength, aRunScript, aAppUnitsPerDevUnit, aFlags);
         }
 
         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;
         }
 
         return new (storage) gfxShapedWord(aText, aLength, aRunScript,
                                            aAppUnitsPerDevUnit, aFlags);
     }
 
     // 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 {
         return &mCharGlyphsStorage[0];
     }
 
     const uint8_t* Text8Bit() const {
         NS_ASSERTION(TextIs8Bit(), "invalid use of Text8Bit()");
--- a/gfx/thebes/gfxImageSurface.cpp
+++ b/gfx/thebes/gfxImageSurface.cpp
@@ -90,17 +90,17 @@ TryAllocAlignedBytes(size_t aSize)
     // Try to align for fast alpha recovery.  This should only help
     // cairo too, can't hurt.
     return moz_posix_memalign(&ptr,
                               1 << gfxAlphaRecovery::GoodAlignmentLog2(),
                               aSize) ?
              nullptr : ptr;
 #else
     // Oh well, hope that luck is with us in the allocator
-    return moz_malloc(aSize);
+    return malloc(aSize);
 #endif
 }
 
 gfxImageSurface::gfxImageSurface(const gfxIntSize& size, gfxImageFormat format, bool aClear)
  : mSize(size), mData(nullptr), mFormat(format)
 {
     AllocateAndInit(0, 0, aClear);
 }
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -101,17 +101,17 @@ NeedsGlyphExtents(gfxTextRun *aTextRun)
 // Helper for textRun creation to preallocate storage for glyph records;
 // this function returns a pointer to the newly-allocated glyph storage.
 // Returns nullptr if allocation fails.
 void *
 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;
     }
 
     // Initialize the glyph storage (beyond aSize) to zero
     memset(reinterpret_cast<char*>(storage) + aSize, 0,
            aLength * sizeof(CompressedGlyph));
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -77,19 +77,19 @@ struct gfxTextRunDrawCallbacks {
  * 
  * It is important that zero-length substrings are handled correctly. This will
  * be on the test!
  */
 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();
 
     typedef gfxFont::RunMetrics Metrics;
 
     // Public textrun API for general use
 
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -670,32 +670,32 @@ gfxUserFontEntry::LoadPlatformFont(const
                  mFontSet, mSrcIndex, fontURI.get(),
                  NS_ConvertUTF16toUTF8(mFamilyName).get()));
         }
 #endif
     }
 
     // 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;
 }
 
 void
 gfxUserFontEntry::Load()
 {
     if (mUserFontLoadState == STATUS_NOT_LOADED) {
         LoadNextSrc();
     }
 }
 
 // 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,
                                            nsresult aDownloadStatus)
 {
     // forget about the loader, as we no longer potentially need to cancel it
     // if the entry is obsoleted
     mLoader = nullptr;
@@ -713,17 +713,17 @@ gfxUserFontEntry::FontDataDownloadComple
     } else {
         // download failed
         mFontSet->LogMessage(this,
                              "download failed", nsIScriptError::errorFlag,
                              aDownloadStatus);
     }
 
     if (aFontData) {
-        moz_free((void*)aFontData);
+        free((void*)aFontData);
     }
 
     // error occurred, load next src
     LoadNextSrc();
 
     // We ignore the status returned by LoadNext();
     // even if loading failed, we need to bump the font-set generation
     // and return true in order to trigger reflow, so that fallback
--- a/image/decoders/nsBMPDecoder.cpp
+++ b/image/decoders/nsBMPDecoder.cpp
@@ -55,17 +55,17 @@ nsBMPDecoder::nsBMPDecoder(RasterImage* 
   , mUseAlphaData(false)
   , mHaveAlphaData(false)
 { }
 
 nsBMPDecoder::~nsBMPDecoder()
 {
   delete[] mColors;
   if (mRow) {
-      moz_free(mRow);
+      free(mRow);
   }
 }
 
 // Sets whether or not the BMP will use alpha data
 void
 nsBMPDecoder::SetUseAlphaData(bool useAlphaData)
 {
   mUseAlphaData = useAlphaData;
@@ -425,17 +425,17 @@ nsBMPDecoder::WriteInternal(const char* 
                 ));
         PostDataError();
         return;
       }
 
       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.
         if (!mRow) {
           PostDataError();
           return;
         }
       }
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -88,18 +88,18 @@ nsGIFDecoder2::nsGIFDecoder2(RasterImage
 
   // Start with the version (GIF89a|GIF87a)
   mGIFStruct.state = gif_type;
   mGIFStruct.bytes_to_consume = 6;
 }
 
 nsGIFDecoder2::~nsGIFDecoder2()
 {
-  moz_free(mGIFStruct.local_colormap);
-  moz_free(mGIFStruct.hold);
+  free(mGIFStruct.local_colormap);
+  free(mGIFStruct.hold);
 }
 
 void
 nsGIFDecoder2::FinishInternal()
 {
   MOZ_ASSERT(!HasError(), "Shouldn't call FinishInternal after error!");
 
   // If the GIF got cut off, handle it anyway
@@ -1156,29 +1156,29 @@ done:
 }
 
 bool
 nsGIFDecoder2::SetHold(const uint8_t* buf1, uint32_t count1,
                        const uint8_t* buf2 /* = nullptr */,
                        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;
   }
 
   memcpy(newHold, buf1, count1);
   if (buf2) {
     memcpy(newHold + count1, buf2, count2);
   }
 
-  moz_free(mGIFStruct.hold);
+  free(mGIFStruct.hold);
   mGIFStruct.hold = newHold;
   mGIFStruct.bytes_in_hold = count1 + count2;
   return true;
 }
 
 Telemetry::ID
 nsGIFDecoder2::SpeedHistogram()
 {
--- a/image/decoders/nsICODecoder.cpp
+++ b/image/decoders/nsICODecoder.cpp
@@ -65,17 +65,17 @@ nsICODecoder::nsICODecoder(RasterImage* 
   mIsPNG = false;
   mRow = nullptr;
   mOldLine = mCurLine = 1; // Otherwise decoder will never start
 }
 
 nsICODecoder::~nsICODecoder()
 {
   if (mRow) {
-    moz_free(mRow);
+    free(mRow);
   }
 }
 
 void
 nsICODecoder::FinishInternal()
 {
   // We shouldn't be called in error cases
   MOZ_ASSERT(!HasError(), "Shouldn't call FinishInternal after error!");
@@ -525,17 +525,17 @@ nsICODecoder::WriteInternal(const char* 
             GetBitsPerPixel() != 32 ||
           !static_cast<nsBMPDecoder*>(mContainedDecoder.get())->
             HasAlphaData()) {
         uint32_t rowSize = ((GetRealWidth() + 31) / 32) * 4; // + 31 to round up
         if (mPos == bmpDataEnd) {
           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;
           }
         }
 
         // Ensure memory has been allocated before decoding.
         MOZ_ASSERT(mRow, "mRow is null");
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -656,25 +656,25 @@ nsPNGDecoder::info_callback(png_structp 
 #ifdef PNG_APNG_SUPPORTED
   }
 #endif
 
   if (decoder->mTransform &&
       (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
     }
   }
 
   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
     }
   }
 
   if (decoder->NeedsNewFrame()) {
     // We know that we need a new frame, so pause input so the decoder
--- a/image/encoders/bmp/nsBMPEncoder.cpp
+++ b/image/encoders/bmp/nsBMPEncoder.cpp
@@ -25,17 +25,17 @@ nsBMPEncoder::nsBMPEncoder() : mImageBuf
                                mCallbackTarget(nullptr),
                                mNotifyThreshold(0)
 {
 }
 
 nsBMPEncoder::~nsBMPEncoder()
 {
   if (mImageBufferStart) {
-    moz_free(mImageBufferStart);
+    free(mImageBufferStart);
     mImageBufferStart = nullptr;
     mImageBufferCurr = nullptr;
   }
 }
 
 // nsBMPEncoder::InitFromData
 //
 // One output option is supported: bpp=<bpp_value>
@@ -128,17 +128,17 @@ nsBMPEncoder::StartImageEncode(uint32_t 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   InitFileHeader(version, bpp, aWidth, aHeight);
   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;
   }
   mImageBufferCurr = mImageBufferStart;
 
   EncodeFileHeader();
   EncodeInfoHeader();
 
@@ -311,17 +311,17 @@ nsBMPEncoder::ParseOptions(const nsAStri
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBMPEncoder::Close()
 {
   if (mImageBufferStart) {
-    moz_free(mImageBufferStart);
+    free(mImageBufferStart);
     mImageBufferStart = nullptr;
     mImageBufferSize = 0;
     mImageBufferReadPoint = 0;
     mImageBufferCurr = nullptr;
   }
 
   return NS_OK;
 }
--- a/image/encoders/ico/nsICOEncoder.cpp
+++ b/image/encoders/ico/nsICOEncoder.cpp
@@ -26,17 +26,17 @@ nsICOEncoder::nsICOEncoder() : mImageBuf
                                mUsePNG(true),
                                mNotifyThreshold(0)
 {
 }
 
 nsICOEncoder::~nsICOEncoder()
 {
   if (mImageBufferStart) {
-    moz_free(mImageBufferStart);
+    free(mImageBufferStart);
     mImageBufferStart = nullptr;
     mImageBufferCurr = nullptr;
   }
 }
 
 // nsICOEncoder::InitFromData
 // Two output options are supported: format=<png|bmp>;bpp=<bpp_value>
 // format specifies whether to use png or bitmap format
@@ -115,17 +115,17 @@ nsICOEncoder::AddImageFrame(const uint8_
     rv = mContainedEncoder->InitFromData(aData, aLength, aWidth, aHeight,
                                          aStride, aInputFormat, noParams);
     NS_ENSURE_SUCCESS(rv, rv);
 
     uint32_t PNGImageBufferSize;
     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;
     }
     mImageBufferCurr = mImageBufferStart;
     mICODirEntry.mBytesInRes = PNGImageBufferSize;
 
     EncodeFileHeader();
     EncodeInfoHeader();
@@ -149,17 +149,17 @@ nsICOEncoder::AddImageFrame(const uint8_
 
     uint32_t andMaskSize = ((GetRealWidth() + 31) / 32) * 4 * // row AND mask
                            GetRealHeight(); // num rows
 
     uint32_t BMPImageBufferSize;
     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;
     }
     mImageBufferCurr = mImageBufferStart;
 
     // Icon files that wrap a BMP file must not include the BITMAPFILEHEADER
     // section at the beginning of the encoded BMP data, so we must skip over
     // BFH_LENGTH bytes when adding the BMP content to the icon file.
@@ -329,17 +329,17 @@ nsICOEncoder::ParseOptions(const nsAStri
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsICOEncoder::Close()
 {
   if (mImageBufferStart) {
-    moz_free(mImageBufferStart);
+    free(mImageBufferStart);
     mImageBufferStart = nullptr;
     mImageBufferSize = 0;
     mImageBufferReadPoint = 0;
     mImageBufferCurr = nullptr;
   }
 
   return NS_OK;
 }
--- a/image/encoders/jpeg/nsJPEGEncoder.cpp
+++ b/image/encoders/jpeg/nsJPEGEncoder.cpp
@@ -34,17 +34,17 @@ nsJPEGEncoder::nsJPEGEncoder()
      mNotifyThreshold(0),
      mReentrantMonitor("nsJPEGEncoder.mReentrantMonitor")
 {
 }
 
 nsJPEGEncoder::~nsJPEGEncoder()
 {
   if (mImageBuffer) {
-    moz_free(mImageBuffer);
+    free(mImageBuffer);
     mImageBuffer = nullptr;
   }
 }
 
 
 // nsJPEGEncoder::InitFromData
 //
 //    One output option is supported: "quality=X" where X is an integer in the
@@ -238,17 +238,17 @@ nsJPEGEncoder::EndImageEncode()
 }
 
 
 /* void close (); */
 NS_IMETHODIMP
 nsJPEGEncoder::Close()
 {
   if (mImageBuffer != nullptr) {
-    moz_free(mImageBuffer);
+    free(mImageBuffer);
     mImageBuffer = nullptr;
     mImageBufferSize = 0;
     mImageBufferUsed = 0;
     mImageBufferReadPoint = 0;
   }
   return NS_OK;
 }
 
@@ -399,17 +399,17 @@ nsJPEGEncoder::ConvertRGBARow(const uint
 
 void // static
 nsJPEGEncoder::initDestination(jpeg_compress_struct* cinfo)
 {
   nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data);
   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;
   cinfo->dest->free_in_buffer = that->mImageBufferSize;
 }
 
 
 // nsJPEGEncoder::emptyOutputBuffer
@@ -433,21 +433,21 @@ nsJPEGEncoder::emptyOutputBuffer(jpeg_co
   // that nobody is trying to read from the buffer we are destroying
   ReentrantMonitorAutoEnter autoEnter(that->mReentrantMonitor);
 
   that->mImageBufferUsed = that->mImageBufferSize;
 
   // 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;
 
     // This seems to be the only way to do errors through the JPEG library.  We
     // pass an nsresult masquerading as an int, which works because the
     // setjmp() caller casts it back.
     longjmp(((encoder_error_mgr*)(cinfo->err))->setjmp_buffer,
--- a/image/encoders/png/nsPNGEncoder.cpp
+++ b/image/encoders/png/nsPNGEncoder.cpp
@@ -37,17 +37,17 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(null
                                mReentrantMonitor(
                                               "nsPNGEncoder.mReentrantMonitor")
 {
 }
 
 nsPNGEncoder::~nsPNGEncoder()
 {
   if (mImageBuffer) {
-    moz_free(mImageBuffer);
+    free(mImageBuffer);
     mImageBuffer = nullptr;
   }
   // don't leak if EndImageEncode wasn't called
   if (mPNG) {
     png_destroy_write_struct(&mPNG, &mPNGinfo);
   }
 }
 
@@ -150,17 +150,17 @@ nsPNGEncoder::StartImageEncode(uint32_t 
     png_destroy_write_struct(&mPNG, &mPNGinfo);
     return NS_ERROR_FAILURE;
   }
 
   // Set up to read the data into our image buffer, start out with an 8K
   // 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;
   }
   mImageBufferUsed = 0;
 
   // set our callback for libpng to give us the data
   png_set_write_fn(mPNG, this, WriteCallback, nullptr);
@@ -527,17 +527,17 @@ nsPNGEncoder::ParseOptions(const nsAStri
 }
 
 
 /* void close (); */
 NS_IMETHODIMP
 nsPNGEncoder::Close()
 {
   if (mImageBuffer != nullptr) {
-    moz_free(mImageBuffer);
+    free(mImageBuffer);
     mImageBuffer = nullptr;
     mImageBufferSize = 0;
     mImageBufferUsed = 0;
     mImageBufferReadPoint = 0;
   }
   return NS_OK;
 }
 
@@ -728,21 +728,21 @@ nsPNGEncoder::WriteCallback(png_structp 
 
   if (that->mImageBufferUsed + size > that->mImageBufferSize) {
     // When we're reallocing the buffer we need to take the lock to ensure
     // that nobody is trying to read from the buffer we are destroying
     ReentrantMonitorAutoEnter autoEnter(that->mReentrantMonitor);
 
     // 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;
       return;
     }
     that->mImageBuffer = newBuf;
   }
   memcpy(&that->mImageBuffer[that->mImageBufferUsed], data, size);
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -156,17 +156,17 @@ imgFrame::imgFrame()
 
 imgFrame::~imgFrame()
 {
 #ifdef DEBUG
   MonitorAutoLock lock(mMonitor);
   MOZ_ASSERT(mAborted || IsImageCompleteInternal());
 #endif
 
-  moz_free(mPalettedImageData);
+  free(mPalettedImageData);
   mPalettedImageData = nullptr;
 }
 
 nsresult
 imgFrame::ReinitForDecoder(const nsIntSize& aImageSize,
                            const nsIntRect& aRect,
                            SurfaceFormat aFormat,
                            uint8_t aPaletteDepth /* = 0 */,
@@ -208,17 +208,17 @@ imgFrame::ReinitForDecoder(const nsIntSi
   mOffset = nsIntPoint();
   mSinglePixelColor = Color();
 
   // Release all surfaces.
   mImageSurface = nullptr;
   mOptSurface = nullptr;
   mVBuf = nullptr;
   mVBufPtr = nullptr;
-  moz_free(mPalettedImageData);
+  free(mPalettedImageData);
   mPalettedImageData = nullptr;
 
   // Reinitialize.
   nsresult rv = InitForDecoder(aImageSize, aRect, aFormat,
                                aPaletteDepth, aNonPremult);
   if (NS_FAILED(rv)) {
     return rv;
   }
@@ -269,20 +269,20 @@ imgFrame::InitForDecoder(const nsIntSize
       NS_ERROR("This Depth is not supported");
       mAborted = true;
       return NS_ERROR_FAILURE;
     }
 
     // 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?");
 
     mVBuf = AllocateBufferForImage(mSize, mFormat);
     if (!mVBuf) {
       mAborted = true;
       return NS_ERROR_OUT_OF_MEMORY;
--- a/intl/hyphenation/hnjalloc.h
+++ b/intl/hyphenation/hnjalloc.h
@@ -9,17 +9,17 @@
  * NULL from memory (re)allocation, so it is essential that we use the
  * "infallible" moz_x* variants here.
  */
 
 #include "mozilla/mozalloc.h"
 
 #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,
  * not just through file paths using stdio, we override the (few) stdio APIs
  * that hyphen.c uses and provide our own reimplementation that calls Gecko
  * i/o methods.
  */
 
--- a/intl/locale/mac/nsCollationMacUC.cpp
+++ b/intl/locale/mac/nsCollationMacUC.cpp
@@ -35,22 +35,22 @@ nsCollationMacUC::~nsCollationMacUC()
 {
 #ifdef DEBUG
   nsresult res =
 #endif
     CleanUpCollator();
   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;
     }
   }
 }
 
 nsresult nsCollationMacUC::ConvertStrength(const int32_t aNSStrength,
                                            UCollationStrength* aICUStrength,
                                            UColAttributeValue* aCaseLevelOut)
@@ -106,17 +106,17 @@ nsresult nsCollationMacUC::ConvertLocale
   NS_ENSURE_ARG_POINTER(aICULocale);
 
   nsAutoString localeString;
   nsresult res = aNSLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_COLLATE"), localeString);
   NS_ENSURE_TRUE(NS_SUCCEEDED(res) && !localeString.IsEmpty(),
                  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;
   }
   strcpy(locale, tmp.get());
 
   *aICULocale = locale;
 
   return NS_OK;
@@ -268,23 +268,23 @@ NS_IMETHODIMP nsCollationMacUC::Allocate
   }
 
   uint32_t maxKeyLen = (1 + stringInLen) * kCollationValueSizeFactor * sizeof(UCCollationValue);
   if (maxKeyLen > mBufferLen) {
     uint32_t newBufferLen = mBufferLen;
     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;
     mBufferLen = newBufferLen;
   }
 
   ItemCount actual;
   OSStatus err = ::UCGetCollationKey(mCollator, (const UniChar*) PromiseFlatString(stringIn).get(),
--- a/intl/uconv/nsScriptableUConv.cpp
+++ b/intl/uconv/nsScriptableUConv.cpp
@@ -34,27 +34,27 @@ nsScriptableUnicodeConverter::ConvertFro
   if (!mEncoder)
     return NS_ERROR_FAILURE;
 
   nsresult rv = NS_OK;
   int32_t inLength = aSrc.Length();
   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;
 
     rv = mEncoder->Convert(flatSrc.get(), &inLength, *_retval, aOutLen);
     if (NS_SUCCEEDED(rv))
     {
       (*_retval)[*aOutLen] = '\0';
       return NS_OK;
     }
-    moz_free(*_retval);
+    free(*_retval);
   }
   *_retval = nullptr;
   return NS_ERROR_FAILURE;
 }
 
 /* ACString ConvertFromUnicode (in AString src); */
 NS_IMETHODIMP
 nsScriptableUnicodeConverter::ConvertFromUnicode(const nsAString& aSrc,
@@ -63,38 +63,38 @@ nsScriptableUnicodeConverter::ConvertFro
   int32_t len;
   char* str;
   nsresult rv = ConvertFromUnicodeWithLength(aSrc, &len, &str);
   if (NS_SUCCEEDED(rv)) {
     // No Adopt on nsACString :(
     if (!_retval.Assign(str, len, mozilla::fallible)) {
       rv = NS_ERROR_OUT_OF_MEMORY;
     }
-    moz_free(str);
+    free(str);
   }
   return rv;
 }
 
 nsresult
 nsScriptableUnicodeConverter::FinishWithLength(char **_retval, int32_t* aLength)
 {
   if (!mEncoder)
     return NS_ERROR_FAILURE;
 
   int32_t finLength = 32;
 
-  *_retval = (char *)moz_malloc(finLength);
+  *_retval = (char *)malloc(finLength);
   if (!*_retval)
     return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv = mEncoder->Finish(*_retval, &finLength);
   if (NS_SUCCEEDED(rv))
     *aLength = finLength;
   else
-    moz_free(*_retval);
+    free(*_retval);
 
   return rv;
 
 }
 
 /* ACString Finish(); */
 NS_IMETHODIMP
 nsScriptableUnicodeConverter::Finish(nsACString& _retval)
@@ -112,17 +112,17 @@ nsScriptableUnicodeConverter::Finish(nsA
   int32_t len;
   char* str;
   nsresult rv = FinishWithLength(&str, &len);
   if (NS_SUCCEEDED(rv)) {
     // No Adopt on nsACString :(
     if (!_retval.Assign(str, len, mozilla::fallible)) {
       rv = NS_ERROR_OUT_OF_MEMORY;
     }
-    moz_free(str);
+    free(str);
   }
   return rv;
 }
 
 /* AString ConvertToUnicode (in ACString src); */
 NS_IMETHODIMP
 nsScriptableUnicodeConverter::ConvertToUnicode(const nsACString& aSrc, nsAString& _retval)
 {
@@ -146,30 +146,30 @@ nsScriptableUnicodeConverter::ConvertFro
 
   nsresult rv = NS_OK;
   int32_t inLength = aCount;
   int32_t outLength;
   rv = mDecoder->GetMaxLength(reinterpret_cast<const char*>(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;
 
     rv = mDecoder->Convert(reinterpret_cast<const char*>(aData),
                            &inLength, buf, &outLength);
     if (NS_SUCCEEDED(rv))
     {
       buf[outLength] = 0;
       if (!_retval.Assign(buf, outLength, mozilla::fallible)) {
         rv = NS_ERROR_OUT_OF_MEMORY;
       }
     }
-    moz_free(buf);
+    free(buf);
     return rv;
   }
   return NS_ERROR_FAILURE;
 
 }
 
 /* void convertToByteArray(in AString aString,
                           [optional] out unsigned long aLen,
@@ -188,19 +188,19 @@ nsScriptableUnicodeConverter::ConvertToB
   nsXPIDLCString str;
   str.Adopt(data, len); // NOTE: This uses the XPIDLCString as a byte array
 
   rv = FinishWithLength(&data, &len);
   if (NS_FAILED(rv))
     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());
   *aLen = str.Length();
   return NS_OK;
 }
 
 /* nsIInputStream convertToInputStream(in AString aString); */
@@ -217,17 +217,17 @@ nsScriptableUnicodeConverter::ConvertToI
   uint8_t* data;
   uint32_t dataLen;
   rv = ConvertToByteArray(aString, &dataLen, &data);
   if (NS_FAILED(rv))
     return rv;
 
   rv = inputStream->AdoptData(reinterpret_cast<char*>(data), dataLen);
   if (NS_FAILED(rv)) {
-    moz_free(data);
+    free(data);
     return rv;
   }
 
   NS_ADDREF(*_retval = inputStream);
   return rv;
 }
 
 /* attribute string charset; */
--- a/ipc/keystore/KeyStore.cpp
+++ b/ipc/keystore/KeyStore.cpp
@@ -104,17 +104,17 @@ status_t BnKeystoreService::onTransact(u
       size_t dataLength = 0;
       int32_t ret = get(name, &data, &dataLength);
 
       reply->writeNoException();
       if (ret == 1) {
         reply->writeInt32(dataLength);
         void* buf = reply->writeInplace(dataLength);
         memcpy(buf, data, dataLength);
-        moz_free(data);
+        free(data);
       } else {
         reply->writeInt32(-1);
       }
       return NO_ERROR;
     } break;
     case GET_PUBKEY: {
       CHECK_INTERFACE(IKeystoreService, data, reply);
       String16 name = data.readString16();
@@ -122,17 +122,17 @@ status_t BnKeystoreService::onTransact(u
       size_t dataLength = 0;
       int32_t ret = get_pubkey(name, &data, &dataLength);
 
       reply->writeNoException();
       if (dataLength > 0 && data != nullptr) {
         reply->writeInt32(dataLength);
         void* buf = reply->writeInplace(dataLength);
         memcpy(buf, data, dataLength);
-        moz_free(data);
+        free(data);
       } else {
         reply->writeInt32(-1);
       }
       reply->writeInt32(ret);
       return NO_ERROR;
     } break;
     case SIGN: {
       CHECK_INTERFACE(IKeystoreService, data, reply);
@@ -148,17 +148,17 @@ status_t BnKeystoreService::onTransact(u
       int32_t ret = sign(name, signData, (size_t)signDataSize, &signResult,
                          &signResultSize);
 
       reply->writeNoException();
       if (signResultSize > 0 && signResult != nullptr) {
         reply->writeInt32(signResultSize);
         void* buf = reply->writeInplace(signResultSize);
         memcpy(buf, signResult, signResultSize);
-        moz_free(signResult);
+        free(signResult);
       } else {
         reply->writeInt32(-1);
       }
       reply->writeInt32(ret);
       return NO_ERROR;
     } break;
     default:
       return NO_ERROR;
@@ -321,17 +321,17 @@ static const char* KEYSTORE_ALLOWED_PREF
 void
 FormatCaData(const char *aCaData, int aCaDataLength,
              const char *aName, const uint8_t **aFormatData,
              size_t *aFormatDataLength)
 {
   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;
   }
 
   *aFormatDataLength = bufSize;
   *aFormatData = (const uint8_t *)buf;
 
@@ -566,17 +566,17 @@ ResponseCode getPublicKey(const char *aK
   }
 
   ScopedSECItem keyItem(PK11_DEREncodePublicKey(publicKey));
   if (!keyItem) {
     return KEY_NOT_FOUND;
   }
 
   size_t bufSize = keyItem->len;
-  char *buf = (char *)moz_malloc(bufSize);
+  char *buf = (char *)malloc(bufSize);
   if (!buf) {
     return SYSTEM_ERROR;
   }
 
   memcpy(buf, keyItem->data, bufSize);
   *aKeyData = (const uint8_t *)buf;
   *aKeyDataLength = bufSize;
 
@@ -642,17 +642,17 @@ ResponseCode signData(const char *aKeyNa
   }
 
   SECStatus srv;
   srv = PK11_Sign(privateKey, signItem.get(), &hashItem);
   if (srv != SECSuccess) {
     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;
   }
 
   memcpy(buf, signItem->data, signItem->len);
   *out = buf;
   *outLength = signItem->len;
 
@@ -1068,17 +1068,17 @@ KeyStore::ReceiveSocketData(nsAutoPtr<Un
           }
           if (result != SUCCESS) {
             break;
           }
 
           SendResponse(SUCCESS);
           SendData(data, (int)dataLength);
 
-          moz_free((void *)data);
+          free((void *)data);
         }
 
         ResetHandlerInfo();
         break;
     }
 
     if (result != SUCCESS) {
       SendResponse(result);
--- a/layout/base/nsBidi.cpp
+++ b/layout/base/nsBidi.cpp
@@ -185,33 +185,33 @@ void nsBidi::Init()
 bool nsBidi::GetMemory(void **aMemory, size_t *aSize, bool aMayAllocate, size_t aSizeNeeded)
 {
   /* check for existing memory */
   if(*aMemory==nullptr) {
     /* we need to allocate memory */
     if(!aMayAllocate) {
       return false;
     } else {
-      *aMemory=moz_malloc(aSizeNeeded);
+      *aMemory=malloc(aSizeNeeded);
       if (*aMemory!=nullptr) {
         *aSize=aSizeNeeded;
         return true;
       } else {
         *aSize=0;
         return false;
       }
     }
   } else {
     /* there is some memory, is it enough or too much? */
     if(aSizeNeeded>*aSize && !aMayAllocate) {
       /* not enough memory, and we must not allocate */
       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;
         *aSize=aSizeNeeded;
         return true;
       } else {
         /* we failed to grow */
         return false;
@@ -220,21 +220,21 @@ bool nsBidi::GetMemory(void **aMemory, s
       /* we have at least enough memory and must not allocate */
       return true;
     }
   }
 }
 
 void nsBidi::Free()
 {
-  moz_free(mDirPropsMemory);
+  free(mDirPropsMemory);
   mDirPropsMemory = nullptr;
-  moz_free(mLevelsMemory);
+  free(mLevelsMemory);
   mLevelsMemory = nullptr;
-  moz_free(mRunsMemory);
+  free(mRunsMemory);
   mRunsMemory = nullptr;
 }
 
 /* SetPara ------------------------------------------------------------ */
 
 nsresult nsBidi::SetPara(const char16_t *aText, int32_t aLength,
                          nsBidiLevel aParaLevel, nsBidiLevel *aEmbeddingLevels)
 {
--- a/layout/generic/nsFontInflationData.cpp
+++ b/layout/generic/nsFontInflationData.cpp
@@ -163,17 +163,17 @@ ComputeDescendantISize(const nsHTMLReflo
 
   MOZ_ASSERT(reflowStates[len - 1].frame == aDescendantFrame,
              "bad logic in this function");
   nscoord result = reflowStates[len - 1].ComputedISize();
 
   for (uint32_t i = len; i-- != 0; ) {
     reflowStates[i].~nsHTMLReflowState();
   }
-  moz_free(reflowStates);
+  free(reflowStates);
 
   return result;
 }
 
 void
 nsFontInflationData::UpdateISize(const nsHTMLReflowState &aReflowState)
 {
   nsIFrame *bfc = aReflowState.frame;
--- a/layout/style/FontFace.cpp
+++ b/layout/style/FontFace.cpp
@@ -45,20 +45,20 @@ FontFaceBufferSource::TakeBuffer(uint8_t
 // -- Utility functions ------------------------------------------------------
 
 template<typename T>
 static void
 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;
   }
   memcpy((void*) aBuffer, aObject.Data(), aObject.Length());
   aLength = aObject.Length();
 }
 
 // -- FontFace ---------------------------------------------------------------
--- a/media/webrtc/signaling/src/common/time_profiling/timecard.c
+++ b/media/webrtc/signaling/src/common/time_profiling/timecard.c
@@ -16,18 +16,18 @@ create_timecard()
   tc->entries = moz_xcalloc(tc->entries_allocated, sizeof(TimecardEntry));
   tc->start_time = PR_Now();
   return tc;
 }
 
 void
 destroy_timecard(Timecard *tc)
 {
-  moz_free(tc->entries);
-  moz_free(tc);
+  free(tc->entries);
+  free(tc);
 }
 
 void
 stamp_timecard(Timecard *tc,
                const char *event,
                const char *file,
                unsigned int line,
                const char *function)
--- a/media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
+++ b/media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
@@ -10,17 +10,17 @@
 #include "cpr_strings.h"
 
 /* From cpr_stdlib.h */
 #include "mozilla/mozalloc.h"
 
 #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)
 
 
 /**
  * sstrncpy
  *
  * This is Cisco's *safe* version of strncpy.  The string will always
  * be NUL terminated (which is not ANSI compliant).
  *
--- a/netwerk/base/nsIStreamLoader.idl
+++ b/netwerk/base/nsIStreamLoader.idl
@@ -22,18 +22,18 @@ interface nsIStreamLoaderObserver : nsIS
      *
      * This method will always be called asynchronously by the
      * nsIStreamLoader involved, on the thread that called the
      * loader's init() method.
      *
      * 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,
                           in nsISupports ctxt,
                           in nsresult status,
                           in unsigned long resultLength,
                           [const,array,size_is(resultLength)] in octet result);
 };
--- a/netwerk/base/nsPreloadedStream.cpp
+++ b/netwerk/base/nsPreloadedStream.cpp
@@ -23,17 +23,17 @@ nsPreloadedStream::nsPreloadedStream(nsI
       mLen(datalen)
 {
     mBuf = (char *) moz_xmalloc(datalen);
     memcpy(mBuf, data, datalen);
 }
 
 nsPreloadedStream::~nsPreloadedStream()
 {
-    moz_free(mBuf);
+    free(mBuf);
 }
 
 NS_IMETHODIMP
 nsPreloadedStream::Close()
 {
     mLen = 0;
     return mStream->Close();
 }
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -98,19 +98,19 @@ nsSocketTransportService::nsSocketTransp
 nsSocketTransportService::~nsSocketTransportService()
 {
     NS_ASSERTION(NS_IsMainThread(), "wrong thread");
     NS_ASSERTION(!mInitialized, "not shutdown properly");
     
     if (mThreadEvent)
         PR_DestroyPollableEvent(mThreadEvent);
 
-    moz_free(mActiveList);
-    moz_free(mIdleList);
-    moz_free(mPollList);
+    free(mActiveList);
+    free(mIdleList);
+    free(mPollList);
     gSocketTransportService = nullptr;
 }
 
 //-----------------------------------------------------------------------------
 // event queue (any thread)
 
 already_AddRefed<nsIThread>
 nsSocketTransportService::GetThreadSafely()
--- a/netwerk/cache/nsCacheMetaData.cpp
+++ b/netwerk/cache/nsCacheMetaData.cpp
@@ -146,17 +146,17 @@ nsCacheMetaData::VisitElements(nsICacheM
     MOZ_ASSERT(data == limit, "Metadata corrupted");
     return NS_OK;
 }
 
 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;
         }
         mBuffer = buf;
         mBufferSize = bufSize;
     }
     return NS_OK;
 }        
--- a/netwerk/cache/nsCacheMetaData.h
+++ b/netwerk/cache/nsCacheMetaData.h
@@ -13,17 +13,17 @@
 class nsICacheMetaDataVisitor;
 
 class nsCacheMetaData {
 public:
     nsCacheMetaData() : mBuffer(nullptr), mBufferSize(0), mMetaSize(0) { }
 
     ~nsCacheMetaData() {
         mBufferSize = mMetaSize = 0;  
-        moz_free(mBuffer);
+        free(mBuffer);
         mBuffer = nullptr;
     }
 
     const char *  GetElement(const char * key);
 
     nsresult      SetElement(const char * key, const char * value);
 
     uint32_t      Size(void) { return mMetaSize; }
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -180,17 +180,17 @@ CacheFileChunk::Read(CacheFileHandle *aH
   MOZ_ASSERT(!mRWBuf);
   MOZ_ASSERT(aLen);
 
   nsresult rv;
 
   mState = READING;
 
   if (CanAllocate(aLen)) {
-    mRWBuf = static_cast<char *>(moz_malloc(aLen));
+    mRWBuf = static_cast<char *>(malloc(aLen));
     if (mRWBuf) {
       mRWBufSize = aLen;
       ChunkAllocationChanged();
     }
   }
 
   if (!mRWBuf) {
     // Allocation was denied or failed
@@ -693,17 +693,17 @@ CacheFileChunk::EnsureBufSize(uint32_t a
   const uint32_t maxBufSize = kChunkSize;
   aBufSize = clamped(aBufSize, minBufSize, maxBufSize);
 
   if (!CanAllocate(aBufSize - mBufSize)) {
     SetError(NS_ERROR_OUT_OF_MEMORY);
     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;
   }
 
   mBuf = newBuf;
   mBufSize = aBufSize;
   ChunkAllocationChanged();
--- a/netwerk/dns/DNS.cpp
+++ b/netwerk/dns/DNS.cpp
@@ -282,18 +282,18 @@ AddrInfo::AddrInfo(const char *host, con
 }
 
 AddrInfo::~AddrInfo()
 {
   NetAddrElement *addrElement;
   while ((addrElement = mAddresses.popLast())) {
     delete addrElement;
   }
-  moz_free(mHostName);
-  moz_free(mCanonicalName);
+  free(mHostName);
+  free(mCanonicalName);
 }
 
 void
 AddrInfo::Init(const char *host, const char *cname)
 {
   MOZ_ASSERT(host, "Cannot initialize AddrInfo with a null host pointer!");
 
   ttl = NO_TTL_DATA;
--- a/netwerk/protocol/http/SpdyZlibReporter.cpp
+++ b/netwerk/protocol/http/SpdyZlibReporter.cpp
@@ -19,17 +19,17 @@ SpdyZlibReporter::Alloc(void*, uInt item
   sAmount += MallocSizeOfOnAlloc(p);
   return p;
 }
 
 /* static */ void
 SpdyZlibReporter::Free(void*, void* p)
 {
   sAmount -= MallocSizeOfOnFree(p);
-  moz_free(p);
+  free(p);
 }
 
 NS_IMETHODIMP
 SpdyZlibReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
                                  nsISupports* aData, bool aAnonymize)
 {
   return MOZ_COLLECT_REPORT(
     "explicit/network/spdy-zlib-buffers", KIND_HEAP, UNITS_BYTES, sAmount,
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -1165,18 +1165,18 @@ WebSocketChannel::~WebSocketChannel()
 
   if (mWasOpened) {
     MOZ_ASSERT(mCalledOnStop, "WebSocket was opened but OnStop was not called");
     MOZ_ASSERT(mStopped, "WebSocket was opened but never stopped");
   }
   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()))
     delete mCurrentOut;
   while ((mCurrentOut = (OutboundMessage *) mOutgoingPongMessages.PopFront()))
     delete mCurrentOut;
   while ((mCurrentOut = (OutboundMessage *) mOutgoingMessages.PopFront()))
     delete mCurrentOut;
@@ -1395,17 +1395,17 @@ WebSocketChannel::UpdateReadBuffer(uint8
     LOG(("WebSocketChannel: update read buffer shifted %u\n", mBuffered));
     ::memmove(mBuffer, mFramePtr - accumulatedFragments, mBuffered);
     mFramePtr = mBuffer + accumulatedFragments;
   } else {
     // existing buffer is not sufficient, extend it
     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;
     }
     mFramePtr = mBuffer + (mFramePtr - old);
   }
 
   ::memcpy(mBuffer + mBuffered, buffer, count);
@@ -1772,17 +1772,17 @@ WebSocketChannel::ProcessInput(uint8_t *
     // If we were working off a saved buffer state and there is no partial
     // frame or fragment in process, then revert to stack behavior
     LOG(("WebSocketChannel:: Internal buffering not needed anymore"));
     mBuffered = 0;
 
     // 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);
     }
   }
   return NS_OK;
 }
 
 void
 WebSocketChannel::ApplyMask(uint32_t mask, uint8_t *data, uint64_t len)
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -1003,34 +1003,34 @@ DataChannelConnection::SendOpenRequestMe
   case SCTP_PR_SCTP_TTL:
     req->channel_type = DATA_CHANNEL_PARTIAL_RELIABLE_TIMED;
     break;
   case SCTP_PR_SCTP_RTX:
     req->channel_type = DATA_CHANNEL_PARTIAL_RELIABLE_REXMIT;
     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) {
     // Per the current types, all differ by 0x80 between ordered and unordered
     req->channel_type |= 0x80; // NOTE: be careful if new types are added in the future
   }
 
   req->reliability_param = htonl(prValue);
   req->priority = htons(0); /* XXX: add support */
   req->label_length = htons(label_len);
   req->protocol_length = htons(proto_len);
   memcpy(&req->label[0], PromiseFlatCString(label).get(), label_len);
   memcpy(&req->label[label_len], PromiseFlatCString(protocol).get(), proto_len);
 
   int32_t result = SendControlMessage(req, req_size, stream);
 
-  moz_free(req);
+  free(req);
   return result;
 }
 
 // XXX This should use a separate thread (outbound queue) which should
 // select() to know when to *try* to send data to the socket again.
 // Alternatively, it can use a timeout, but that's guaranteed to be wrong
 // (just not sure in what direction).  We could re-implement NSPR's
 // PR_POLL_WRITE/etc handling... with a lot of work.
@@ -1726,17 +1726,17 @@ DataChannelConnection::SendOutgoingStrea
     // if errno == EALREADY, this is normal - we can't send another reset
     // with one pending.
     // When we get an incoming reset (which may be a response to our
     // outstanding one), see if we have any pending outgoing resets and
     // send them
   } else {
     mStreamsResetting.Clear();
   }
-  moz_free(srs);
+  free(srs);
 }
 
 void
 DataChannelConnection::HandleStreamResetEvent(const struct sctp_stream_reset_event *strrst)
 {
   uint32_t n, i;
   nsRefPtr<DataChannel> channel; // since we may null out the ref to the channel
 
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -78,17 +78,17 @@ public:
     , mLength(length)
   {
     mData = static_cast<char *>(moz_xmalloc(length)); // infallible
     memcpy(mData, data, length);
   }
 
   ~QueuedDataMessage()
   {
-    moz_free(mData);
+    free(mData);
   }
 
   uint16_t mStream;
   uint32_t mPpid;
   size_t   mLength;
   char     *mData;
 };
 
--- a/netwerk/streamconv/converters/nsBinHexDecoder.cpp
+++ b/netwerk/streamconv/converters/nsBinHexDecoder.cpp
@@ -437,18 +437,18 @@ int16_t nsBinHexDecoder::GetNextChar(uin
 
 NS_IMETHODIMP
 nsBinHexDecoder::OnStartRequest(nsIRequest* request, nsISupports *aCtxt)
 {
   nsresult rv = NS_OK;
 
   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...
   rv = NS_NewPipe(getter_AddRefs(mInputStream), getter_AddRefs(mOutputStream),
                   nsIOService::gDefaultSegmentSize,
                   nsIOService::gDefaultSegmentSize,
                   true, true);
 
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -146,30 +146,30 @@ nsHTTPCompressConv::OnDataAvailable(nsIR
                 return NS_OK;
 
             // FALLTHROUGH
 
         case HTTP_COMPRESS_DEFLATE:
 
             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;
 
             uint32_t unused;
             iStr->Read((char *)mInpBuffer, streamLen, &unused);
 
             if (mMode == HTTP_COMPRESS_DEFLATE)
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -475,17 +475,17 @@ nsHtml5StreamParser::FinalizeSniffing(co
   NS_ASSERTION(IsParserThread(), "Wrong thread!");
   NS_ASSERTION(mCharsetSource < kCharsetFromParentForced,
       "Should not finalize sniffing when using forced charset.");
   if (mMode == VIEW_SOURCE_XML) {
     static const XML_Memory_Handling_Suite memsuite =
       {
         (void *(*)(size_t))moz_xmalloc,
         (void *(*)(void *, size_t))moz_xrealloc,
-        moz_free
+        free
       };
 
     static const char16_t kExpatSeparator[] = { 0xFFFF, '\0' };
 
     static const char16_t kISO88591[] =
         { 'I', 'S', 'O', '-', '8', '8', '5', '9', '-', '1', '\0' };
 
     UserData ud;
--- a/rdf/base/nsRDFContentSink.cpp
+++ b/rdf/base/nsRDFContentSink.cpp
@@ -338,17 +338,17 @@ RDFContentSinkImpl::~RDFContentSinkImpl(
             }
 #endif
 
             NS_IF_RELEASE(resource);
         }
 
         delete mContextStack;
     }
-    moz_free(mText);
+    free(mText);
 
 
     if (--gRefCnt == 0) {
         NS_IF_RELEASE(gRDFService);
         NS_IF_RELEASE(gRDFContainerUtils);
         NS_IF_RELEASE(kRDF_type);
         NS_IF_RELEASE(kRDF_instanceOf);
         NS_IF_RELEASE(kRDF_Alt);
@@ -750,17 +750,17 @@ RDFContentSinkImpl::FlushText()
 }
 
 
 nsresult
 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;
         }
         mTextSize = 4096;
     }
 
     // Copy data from string into our buffer; grow the buffer as needed.
     // It never shrinks, but since the content sink doesn't stick around,
@@ -768,17 +768,17 @@ RDFContentSinkImpl::AddText(const char16
     int32_t amount = mTextSize - mTextLength;
     if (amount < aLength) {
         // Grow the buffer by at least a factor of two to prevent thrashing.
         // Since PR_REALLOC will leave mText intact if the call fails,
         // don't clobber mText or mTextSize until the new mem is allocated.
         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;
         mText = newText;
     }
     memcpy(&mText[mTextLength], aText, sizeof(char16_t) * aLength);
     mTextLength += aLength;
 
--- a/security/manager/ssl/src/nsNSSCallbacks.cpp
+++ b/security/manager/ssl/src/nsNSSCallbacks.cpp
@@ -604,17 +604,17 @@ nsHTTPListener::nsHTTPListener()
 }
 
 nsHTTPListener::~nsHTTPListener()
 {
   if (mResponsibleForDoneSignal)
     send_done_signal();
 
   if (mResultData) {
-    moz_free(const_cast<uint8_t *>(mResultData));
+    free(const_cast<uint8_t *>(mResultData));
   }
 
   if (mLoader) {
     nsCOMPtr<nsIThread> mainThread(do_GetMainThread());
     NS_ProxyRelease(mainThread, mLoader);
   }
 }
 
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -397,20 +397,20 @@ namespace {
 // to 2048 bytes, wasting 1012 bytes.  (See bug 676189 for more details.)
 //
 // So we register jemalloc as the malloc implementation, which avoids this
 // 8-byte overhead, and thus a lot of waste.  This requires us to provide a
 // function, sqliteMemRoundup(), which computes the actual size that will be
 // 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
 
 // sqlite does its own memory accounting, and we use its numbers in our memory
 // reporters.  But we don't want sqlite's heap blocks to show up in DMD's
 // output as unreported, so we mark them as reported when they're allocated and
 // mark them as unreported when they are freed.
 //
@@ -424,45 +424,45 @@ namespace {
 
 MOZ_DEFINE_MALLOC_SIZE_OF_ON_ALLOC(SqliteMallocSizeOfOnAlloc)
 MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(SqliteMallocSizeOfOnFree)
 
 #endif
 
 static void *sqliteMemMalloc(int n)
 {
-  void* p = ::moz_malloc(n);
+  void* p = ::malloc(n);
 #ifdef MOZ_DMD
   gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
 #endif
   return p;
 }
 
 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 {
     // realloc failed;  undo the SqliteMallocSizeOfOnFree from above
     gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p);
   }
   return pnew;
 #else
-  return ::moz_realloc(p, n);
+  return ::realloc(p, n);
 #endif
 }
 
 static int sqliteMemSize(void *p)
 {
   return ::moz_malloc_usable_size(p);
 }
 
--- a/xpcom/base/nsMemoryImpl.cpp
+++ b/xpcom/base/nsMemoryImpl.cpp
@@ -213,16 +213,16 @@ XPCOM_API(void*)
 NS_Realloc(void* aPtr, size_t aSize)
 {
   return moz_xrealloc(aPtr, aSize);
 }
 
 XPCOM_API(void)
 NS_Free(void* aPtr)
 {
-  moz_free(aPtr);
+  free(aPtr);
 }
 
 nsresult
 NS_GetMemoryManager(nsIMemory** aResult)
 {
   return sGlobalMemory.QueryInterface(NS_GET_IID(nsIMemory), (void**)aResult);
 }
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -162,35 +162,35 @@ struct nsTArrayInfallibleAllocatorBase
   }
 };
 
 #if defined(MOZALLOC_HAVE_XMALLOC)
 #include "mozilla/mozalloc_abort.h"
 
 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) {}
 };
 
 struct nsTArrayInfallibleAllocator : nsTArrayInfallibleAllocatorBase
 {
   static void* Malloc(size_t aSize) { return moz_xmalloc(aSize); }
   static void* Realloc(void* aPtr, size_t 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); }
 };
 
 #else
 #include <stdlib.h>
 
 struct nsTArrayFallibleAllocator : nsTArrayFallibleAllocatorBase
 {
--- a/xpcom/io/nsBinaryStream.cpp
+++ b/xpcom/io/nsBinaryStream.cpp
@@ -223,26 +223,26 @@ nsBinaryOutputStream::WriteWStringZ(cons
   rv = WriteBytes(reinterpret_cast<const char*>(aString), byteCount);
 #else
   // XXX use WriteSegments here to avoid copy!
   char16_t* copy;
   char16_t temp[64];
   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;
     }
   }
   NS_ASSERTION((uintptr_t(aString) & 0x1) == 0, "aString not properly aligned");
   mozilla::NativeEndian::copyAndSwapToBigEndian(copy, aString, length);
   rv = WriteBytes(reinterpret_cast<const char*>(copy), byteCount);
   if (copy != temp) {
-    moz_free(copy);
+    free(copy);
   }
 #endif
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsBinaryOutputStream::WriteUtf8Z(const char16_t* aString)
@@ -793,28 +793,28 @@ nsBinaryInputStream::ReadString(nsAStrin
 
 NS_IMETHODIMP
 nsBinaryInputStream::ReadBytes(uint32_t aLength, char** aResult)
 {
   nsresult rv;
   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;
   }
 
   *aResult = s;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -1740,17 +1740,17 @@ nsLocalFile::GetVersionInfoField(const c
           if (!aResult.IsEmpty()) {
             rv = NS_OK;
             break;
           }
         }
       }
     }
   }
-  moz_free(ver);
+  free(ver);
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsLocalFile::SetShortcut(nsIFile* aTargetFile,
                          nsIFile* aWorkingDir,
                          const char16_t* aArgs,
--- a/xpcom/io/nsScriptableInputStream.cpp
+++ b/xpcom/io/nsScriptableInputStream.cpp
@@ -53,17 +53,17 @@ nsScriptableInputStream::Read(uint32_t a
   rv = mInputStream->Available(&count64);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // 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;
   }
 
   rv = ReadHelper(buffer, count);
   if (NS_FAILED(rv)) {
     nsMemory::Free(buffer);
     return rv;
--- a/xpcom/io/nsSegmentedBuffer.cpp
+++ b/xpcom/io/nsSegmentedBuffer.cpp
@@ -59,72 +59,72 @@ nsSegmentedBuffer::AppendNewSegment()
              (newArraySize - mLastSegmentIndex) * sizeof(char*));
     } else {
       memset(&mSegmentArray[mLastSegmentIndex], 0,
              (newArraySize - mLastSegmentIndex) * sizeof(char*));
     }
     mSegmentArrayCount = newArraySize;
   }
 
-  char* seg = (char*)moz_malloc(mSegmentSize);
+  char* seg = (char*)malloc(mSegmentSize);
   if (!seg) {
     return nullptr;
   }
   mSegmentArray[mLastSegmentIndex] = seg;
   mLastSegmentIndex = ModSegArraySize(mLastSegmentIndex + 1);
   return seg;
 }
 
 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) {
     mLastSegmentIndex = last;
     return true;
   } else {
     mFirstSegmentIndex = ModSegArraySize(mFirstSegmentIndex + 1);
     return false;
   }
 }
 
 bool
 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);
 }
 
 bool
 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;
   }
   return false;
 }
 
 void
 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);
     mSegmentArray = nullptr;
   }
   mSegmentArrayCount = NS_SEGMENTARRAY_INITIAL_COUNT;
   mFirstSegmentIndex = mLastSegmentIndex = 0;
 }
--- a/xpcom/typelib/xpt/moz.build
+++ b/xpcom/typelib/xpt/moz.build
@@ -26,13 +26,13 @@ GENERATED_INCLUDES += ['/xpcom/base']
 LOCAL_INCLUDES += ['/xpcom/base']
 
 FAIL_ON_WARNINGS = True
 
 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