Bug 991227 - Replace std::auto_ptr with nsAuto(Array)Ptr in LayerScope. r=dglastonbury
authorBoris Chiou <boris.chiou@gmail.com>
Sat, 05 Jul 2014 11:34:00 +0200
changeset 192670 84f3f9b84bbb784fff7d275dc2a7668f5f9ec8f4
parent 192669 2ec6c5b1d1d2c68c7a836e01f909d8532ec07595
child 192671 93b9e0b5a34bd9c8ac0e783762a6a2e8ee36fc97
push id27093
push userkwierso@gmail.com
push dateMon, 07 Jul 2014 23:01:28 +0000
treeherdermozilla-central@7f9db2379b3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdglastonbury
bugs991227
milestone33.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 991227 - Replace std::auto_ptr with nsAuto(Array)Ptr in LayerScope. r=dglastonbury std::auto_ptr causes clang 3.5 build warnings because we shouldn't use std::auto_ptr in C++ 11 anymore. auto_ptr is deprecated in clang 3.5. Therefore I replaced all the std::auto_ptrs in LayerScope.cpp. Note: nsAuto(Array)Ptr should use "new" operator in C++, instead of moz_malloc() because the destructor of nsAuto(Array)Ptr will call delete(delete []).
gfx/layers/LayerScope.cpp
--- a/gfx/layers/LayerScope.cpp
+++ b/gfx/layers/LayerScope.cpp
@@ -484,17 +484,17 @@ public:
     GLenum GetTextureTarget() const { return mTarget; }
 
     virtual bool Write() {
         // write the packet header data
         if (!WriteToStream(&mPacket, sizeof(mPacket)))
             return false;
 
         // then the image data
-        if (mCompresseddata.get() && !WriteToStream(mCompresseddata.get(), mDatasize))
+        if (mCompresseddata.get() && !WriteToStream(mCompresseddata, mDatasize))
             return false;
 
         // then pad out to 4 bytes
         if (mDatasize % 4 != 0) {
             static char buf[] = { 0, 0, 0, 0 };
             if (!WriteToStream(buf, 4 - (mDatasize % 4)))
                 return false;
         }
@@ -513,22 +513,22 @@ private:
         mPacket.dataFormat = LOCAL_GL_RGBA;
 
         if (aImage) {
             mPacket.width = aImage->GetSize().width;
             mPacket.height = aImage->GetSize().height;
             mPacket.stride = aImage->Stride();
             mPacket.dataSize = aImage->GetSize().height * aImage->Stride();
 
-            mCompresseddata = std::auto_ptr<char>(
-                (char*)moz_malloc(LZ4::maxCompressedSize(mPacket.dataSize)));
+            mCompresseddata =
+                new char[LZ4::maxCompressedSize(mPacket.dataSize)];
             if (mCompresseddata.get()) {
                 int ndatasize = LZ4::compress((char*)aImage->GetData(),
                                               mPacket.dataSize,
-                                              mCompresseddata.get());
+                                              mCompresseddata);
                 if (ndatasize > 0) {
                     mDatasize = ndatasize;
 
                     mPacket.dataFormat = (1 << 16) | mPacket.dataFormat;
                     mPacket.dataSize = mDatasize;
                 } else {
                     NS_WARNING("Compress data failed");
                 }
@@ -545,17 +545,17 @@ private:
 
 protected:
     void* mLayerRef;
     GLenum mTarget;
     GLuint mName;
 
     // Packet data
     DebugGLData::TexturePacket mPacket;
-    std::auto_ptr<char> mCompresseddata;
+    nsAutoArrayPtr<char> mCompresseddata;
     uint32_t mDatasize;
 };
 
 class DebugGLColorData : public DebugGLData {
 public:
     DebugGLColorData(void* layerRef, const gfxRGBA& color, int width, int height)
         : DebugGLData(DebugGLData::ColorData),
           mLayerRef(layerRef),
@@ -646,17 +646,17 @@ public:
 
     /* nsIRunnable impl; send the data */
 
     NS_IMETHODIMP Run() {
         DebugGLData *d;
         nsresult rv = NS_OK;
 
         while ((d = mList.popFirst()) != nullptr) {
-            std::auto_ptr<DebugGLData> cleaner(d);
+            nsAutoPtr<DebugGLData> cleaner(d);
             if (!d->Write()) {
                 rv = NS_ERROR_FAILURE;
                 break;
             }
         }
 
         Cleanup();