nsExpirationTracker-GC-TArray
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 160 fd41ae75c7983b0c8aeff594c5c4cb25cde2ce5e
permissions -rw-r--r--
State as of now

diff --git a/xpcom/ds/nsExpirationTracker.h b/xpcom/ds/nsExpirationTracker.h
--- a/xpcom/ds/nsExpirationTracker.h
+++ b/xpcom/ds/nsExpirationTracker.h
@@ -127,7 +127,7 @@ template <class T, PRUint32 K> class nsE
     nsresult AddObject(T* aObj) {
       nsExpirationState* state = aObj->GetExpirationState();
       NS_ASSERTION(!state->IsTracked(), "Tried to add an object that's already tracked");
-      nsTArray<T*>& generation = mGenerations[mNewestGeneration];
+      nsTArray<T*, GCAllocator>& generation = mGenerations[mNewestGeneration];
       PRUint32 index = generation.Length();
       if (index > nsExpirationState::MAX_INDEX_IN_GENERATION) {
         NS_WARNING("More than 256M elements tracked, this is probably a problem");
@@ -152,7 +152,7 @@ template <class T, PRUint32 K> class nsE
     void RemoveObject(T* aObj) {
       nsExpirationState* state = aObj->GetExpirationState();
       NS_ASSERTION(state->IsTracked(), "Tried to remove an object that's not tracked");
-      nsTArray<T*>& generation = mGenerations[state->mGeneration];
+      nsTArray<T*, GCAllocator>& generation = mGenerations[state->mGeneration];
       PRUint32 index = state->mIndexInGeneration;
       NS_ASSERTION(generation.Length() > index &&
                    generation[index] == aObj, "Object is lying about its index");
@@ -195,7 +195,7 @@ template <class T, PRUint32 K> class nsE
       mInAgeOneGeneration = PR_TRUE;
       PRUint32 reapGeneration = 
         mNewestGeneration > 0 ? mNewestGeneration - 1 : K - 1;
-      nsTArray<T*>& generation = mGenerations[reapGeneration];
+      nsTArray<T*, GCAllocator>& generation = mGenerations[reapGeneration];
       // The following is rather tricky. We have to cope with objects being
       // removed from this generation either because of a call to RemoveObject
       // (or indirectly via MarkUsed) inside NotifyExpired. Fortunately no
@@ -250,7 +250,7 @@ template <class T, PRUint32 K> class nsE
         : mTracker(aTracker), mGeneration(0), mIndex(0) {}
       T* Next() {
         while (mGeneration < K) {
-          nsTArray<T*>* generation = &mTracker->mGenerations[mGeneration];
+          nsTArray<T*, GCAllocator>* generation = &mTracker->mGenerations[mGeneration];
           if (mIndex < generation->Length()) {
             ++mIndex;
             return (*generation)[mIndex - 1];
@@ -292,7 +292,7 @@ template <class T, PRUint32 K> class nsE
     virtual void NotifyExpired(T* aObj) = 0;
 
   private:
-    nsTArray<T*>       mGenerations[K];
+    nsTArray<T*, GCAllocator> mGenerations[K];
     nsCOMPtr<nsITimer> mTimer;
     PRUint32           mTimerPeriod;
     PRUint32           mNewestGeneration;