bug 797445 - remove prmem.h from imagelib r=joe
authorTrevor Saunders <trev.saunders@gmail.com>
Wed, 03 Oct 2012 14:10:31 -0400
changeset 118644 159fca947bfac884b29a2bf641fb74fe0fd6c69a
parent 118643 b3c814e2d015fb6f98a3fd82dffb4363f367dc86
child 118645 73651efc5d719bd7940854e54993fa12a1bf54f8
push id273
push userlsblakk@mozilla.com
push dateThu, 14 Feb 2013 23:19:38 +0000
treeherdermozilla-release@c5e807a3f8b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs797445
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 797445 - remove prmem.h from imagelib r=joe
image/decoders/nsGIFDecoder2.cpp
image/encoders/bmp/nsBMPEncoder.cpp
image/encoders/ico/nsICOEncoder.cpp
image/encoders/jpeg/nsJPEGEncoder.cpp
image/encoders/png/nsPNGEncoder.cpp
image/src/RasterImage.cpp
image/src/imgFrame.cpp
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -34,17 +34,16 @@ For further information, please contact 
 
 CompuServe Incorporated maintains a mailing list with all those individuals and
 organizations who wish to receive copies of this document when it is corrected
 or revised. This service is offered free of charge; please provide us with your
 mailing address.
 */
 
 #include <stddef.h>
-#include "prmem.h"
 
 #include "nsGIFDecoder2.h"
 #include "nsIInputStream.h"
 #include "imgIContainerObserver.h"
 #include "RasterImage.h"
 
 #include "gfxColor.h"
 #include "gfxPlatform.h"
--- a/image/encoders/bmp/nsBMPEncoder.cpp
+++ b/image/encoders/bmp/nsBMPEncoder.cpp
@@ -1,16 +1,15 @@
 /* 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/. */
 
 #include "nsCRT.h"
 #include "EndianMacros.h"
 #include "nsBMPEncoder.h"
-#include "prmem.h"
 #include "prprf.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 #include "nsAutoPtr.h"
 
 using namespace mozilla;
 
 NS_IMPL_THREADSAFE_ISUPPORTS3(nsBMPEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)
--- a/image/encoders/ico/nsICOEncoder.cpp
+++ b/image/encoders/ico/nsICOEncoder.cpp
@@ -2,17 +2,16 @@
  * 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/. */
 
 #include "nsCRT.h"
 #include "EndianMacros.h"
 #include "nsBMPEncoder.h"
 #include "nsPNGEncoder.h"
 #include "nsICOEncoder.h"
-#include "prmem.h"
 #include "prprf.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 
 NS_IMPL_THREADSAFE_ISUPPORTS3(nsICOEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)
--- a/image/encoders/jpeg/nsJPEGEncoder.cpp
+++ b/image/encoders/jpeg/nsJPEGEncoder.cpp
@@ -1,15 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
 #include "nsJPEGEncoder.h"
-#include "prmem.h"
 #include "prprf.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 #include "gfxColor.h"
 
 #include <setjmp.h>
 #include "jerror.h"
 
@@ -30,17 +29,17 @@ nsJPEGEncoder::nsJPEGEncoder() : mFinish
                                  mCallbackTarget(nullptr), mNotifyThreshold(0),
                                  mReentrantMonitor("nsJPEGEncoder.mReentrantMonitor")
 {
 }
 
 nsJPEGEncoder::~nsJPEGEncoder()
 {
   if (mImageBuffer) {
-    PR_Free(mImageBuffer);
+    moz_free(mImageBuffer);
     mImageBuffer = nullptr;
   }
 }
 
 
 // nsJPEGEncoder::InitFromData
 //
 //    One output option is supported: "quality=X" where X is an integer in the
@@ -221,17 +220,17 @@ NS_IMETHODIMP nsJPEGEncoder::EndImageEnc
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 
 /* void close (); */
 NS_IMETHODIMP nsJPEGEncoder::Close()
 {
   if (mImageBuffer != nullptr) {
-    PR_Free(mImageBuffer);
+    moz_free(mImageBuffer);
     mImageBuffer = nullptr;
     mImageBufferSize = 0;
     mImageBufferUsed = 0;
     mImageBufferReadPoint = 0;
   }
   return NS_OK;
 }
 
@@ -368,17 +367,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*)PR_Malloc(that->mImageBufferSize);
+  that->mImageBuffer = (uint8_t*)moz_malloc(that->mImageBufferSize);
   that->mImageBufferUsed = 0;
 
   cinfo->dest->next_output_byte = that->mImageBuffer;
   cinfo->dest->free_in_buffer = that->mImageBufferSize;
 }
 
 
 // nsJPEGEncoder::emptyOutputBuffer
@@ -402,21 +401,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*)PR_Realloc(that->mImageBuffer,
-                                         that->mImageBufferSize);
+  uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
+                                          that->mImageBufferSize);
   if (! newBuf) {
     // can't resize, just zero (this will keep us from writing more)
-    PR_Free(that->mImageBuffer);
+    moz_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
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
 #include "nsCRT.h"
 #include "nsPNGEncoder.h"
-#include "prmem.h"
 #include "prprf.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 
 using namespace mozilla;
 
 NS_IMPL_THREADSAFE_ISUPPORTS3(nsPNGEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)
 
@@ -23,17 +22,17 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(null
                                mCallbackTarget(nullptr), mNotifyThreshold(0),
                                mReentrantMonitor("nsPNGEncoder.mReentrantMonitor")
 {
 }
 
 nsPNGEncoder::~nsPNGEncoder()
 {
   if (mImageBuffer) {
-    PR_Free(mImageBuffer);
+    moz_free(mImageBuffer);
     mImageBuffer = nullptr;
   }
   // don't leak if EndImageEncode wasn't called
   if (mPNG)
     png_destroy_write_struct(&mPNG, &mPNGinfo);
 }
 
 // nsPNGEncoder::InitFromData
@@ -128,17 +127,17 @@ NS_IMETHODIMP nsPNGEncoder::StartImageEn
     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*)PR_Malloc(mImageBufferSize);
+  mImageBuffer = (uint8_t*)moz_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);
@@ -477,17 +476,17 @@ nsPNGEncoder::ParseOptions(const nsAStri
   return NS_OK;
 }
 
 
 /* void close (); */
 NS_IMETHODIMP nsPNGEncoder::Close()
 {
   if (mImageBuffer != nullptr) {
-    PR_Free(mImageBuffer);
+    moz_free(mImageBuffer);
     mImageBuffer = nullptr;
     mImageBufferSize = 0;
     mImageBufferUsed = 0;
     mImageBufferReadPoint = 0;
   }
   return NS_OK;
 }
 
@@ -674,21 +673,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*)PR_Realloc(that->mImageBuffer,
-                                           that->mImageBufferSize);
+    uint8_t* newBuf = (uint8_t*)moz_realloc(that->mImageBuffer,
+                                            that->mImageBufferSize);
     if (! newBuf) {
       // can't resize, just zero (this will keep us from writing more)
-      PR_Free(that->mImageBuffer);
+      moz_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/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -10,17 +10,16 @@
 #include "nsError.h"
 #include "Decoder.h"
 #include "imgIDecoderObserver.h"
 #include "RasterImage.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsAutoPtr.h"
 #include "nsStringStream.h"
-#include "prmem.h"
 #include "prenv.h"
 #include "ImageContainer.h"
 #include "Layers.h"
 
 #include "nsPNGDecoder.h"
 #include "nsGIFDecoder2.h"
 #include "nsJPEGDecoder.h"
 #include "nsBMPDecoder.h"
--- a/image/src/imgFrame.cpp
+++ b/image/src/imgFrame.cpp
@@ -4,17 +4,16 @@
  * 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/. */
 
 #include "imgFrame.h"
 #include "DiscardTracker.h"
 
 #include <limits.h>
 
-#include "prmem.h"
 #include "prenv.h"
 
 #include "gfxPlatform.h"
 #include "gfxUtils.h"
 
 static bool gDisableOptimize = false;
 
 #include "cairo.h"
@@ -127,17 +126,18 @@ imgFrame::imgFrame() :
       gDisableOptimize = true;
     }
     hasCheckedOptimize = true;
   }
 }
 
 imgFrame::~imgFrame()
 {
-  PR_FREEIF(mPalettedImageData);
+  moz_free(mPalettedImageData);
+  mPalettedImageData = nullptr;
 #ifdef USE_WIN_SURFACE
   if (mIsDDBSurface) {
       gTotalDDBs--;
       gTotalDDBSize -= mSize.width * mSize.height * 4;
   }
 #endif
 
   if (mInformedDiscardTracker) {