Bug 464043 - change nsDeque to use malloc for mData, r=bsmedberg
authortimeless@mozdev.org
Sat, 14 Nov 2009 16:45:42 -0800
changeset 33670 26d330339592a6e6a4841518023ffd5fa4d7dafe
parent 33669 0d17e450afbee11fac48ba5506c587eb185dad82
child 33671 353af8416a4f01ddc6de89483fc6d4c0ee209563
push id1118
push usertimeless@mozdev.org
push dateFri, 05 Mar 2010 15:09:07 +0000
reviewersbsmedberg
bugs464043
milestone1.9.2.2pre
Bug 464043 - change nsDeque to use malloc for mData, r=bsmedberg a=beltzner
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;
 }