Bug 464043 - change nsDeque to use malloc for mData, r=bsmedberg
authortimeless@mozdev.org
Sat, 14 Nov 2009 16:45:42 -0800
changeset 34868 586c7fa4491f36a4a84c139d6294c5e3e7329ffb
parent 34867 0d98ff9aef326d8cf2a9a12d9d70c2bfc3a0790c
child 34869 d49d4151ad1d5e1aa422586d7d0fa09371aab565
push id10314
push userphilringnalda@gmail.com
push dateSun, 15 Nov 2009 00:46:21 +0000
treeherdermozilla-central@586c7fa4491f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs464043
milestone1.9.3a1pre
Bug 464043 - change nsDeque to use malloc for mData, r=bsmedberg
xpcom/glue/nsDeque.cpp
--- a/xpcom/glue/nsDeque.cpp
+++ b/xpcom/glue/nsDeque.cpp
@@ -111,17 +111,17 @@ nsDeque::~nsDeque() {
     case 4096:  mCaps[10]++; break;
     default:
       break;
   }
 #endif
 
   Erase();
   if (mData && (mData!=mBuffer)) {
-    delete [] mData;
+    free(mData);
   }
   mData=0;
   SetDeallocator(0);
 }
 
 /**
  * Set the functor to be called by Erase()
  * The deque owns the functor.
@@ -171,30 +171,30 @@ nsDeque& nsDeque::Erase() {
  *
  * @return  whether growing succeeded
  */
 PRBool nsDeque::GrowCapacity() {
   PRInt32 theNewSize=mCapacity<<2;
   NS_ASSERTION(theNewSize>mCapacity, "Overflow");
   if (theNewSize<=mCapacity)
     return PR_FALSE;
-  void** temp=new void*[theNewSize];
+  void** temp=(void**)malloc(theNewSize * sizeof(void*));
   if (!temp)
     return PR_FALSE;
 
   //Here's the interesting part: You can't just move the elements
   //directly (in situ) from the old buffer to the new one.
   //Since capacity has changed, the old origin doesn't make
   //sense anymore. It's better to resequence the elements now.
 
   memcpy(temp, mData + mOrigin, sizeof(void*) * (mCapacity - mOrigin));
   memcpy(temp + (mCapacity - mOrigin), mData, sizeof(void*) * mOrigin);
 
   if (mData != mBuffer) {
-    delete [] mData;
+    free(mData);
   }
 
   mCapacity=theNewSize;
   mOrigin=0; //now realign the origin...
   mData=temp;
 
   return PR_TRUE;
 }