Bug 1247093 - Replace nsBaseHashtable::Enumerate() calls in purplexpcom. r=njn
authoraleth <aleth@instantbird.org>
Tue, 09 Feb 2016 23:59:36 +0100
changeset 783 270af9e2de0ea92f71772897dcf1586bc57cfa8e
parent 782 17fc639a64bdf4a481068e2e91b54f3de8de5d3e
child 784 69428cd068a15eb4c8b828b049308481b2426f2f
push id59
push useraleth@instantbird.org
push dateTue, 09 Feb 2016 23:45:38 +0000
reviewersnjn
bugs1247093
Bug 1247093 - Replace nsBaseHashtable::Enumerate() calls in purplexpcom. r=njn
purplexpcom/src/purpleGetText.cpp
--- a/purplexpcom/src/purpleGetText.cpp
+++ b/purplexpcom/src/purpleGetText.cpp
@@ -483,36 +483,32 @@ nsresult purpleGetText::init()
       do_GetService("@mozilla.org/observer-service;1");
     if (os)
       os->AddObserver(sInstance, NS_CHROME_FLUSH_TOPIC, PR_FALSE);
   }
 
   return NS_OK;
 }
 
-// Used to delete all the elements of a nsDataHashtable
-static PLDHashOperator deleteEnumerator(const nsACString &aKey,
-                                        nsTArray<nsCString> *&aArray,
-                                        void *aUserArg)
-{
-  delete aArray;
-
-  return (PLDHashOperator) (PL_DHASH_REMOVE | PL_DHASH_NEXT);
-}
-
 void purpleGetText::unInit()
 {
   if (!sInstance)
     return;
 
   nsCOMPtr<nsIObserverService> os =
     do_GetService("@mozilla.org/observer-service;1");
   if (os)
     os->RemoveObserver(sInstance, NS_CHROME_FLUSH_TOPIC);
 
   LOG(("purpleGetText::unInit\n"));
-  for (PRUint32 i = 0; i < sInstance->mStringCache.Length(); ++i)
-    if (sInstance->mStringCache[i].table)
-      sInstance->mStringCache[i].table->Enumerate(deleteEnumerator, nullptr);
+  for (PRUint32 i = 0; i < sInstance->mStringCache.Length(); ++i) {
+    if (sInstance->mStringCache[i].table) {
+      for (auto iter = sInstance->mStringCache[i].table->Iter();
+           !iter.Done(); iter.Next()) {
+        delete iter.Data();
+        iter.Remove();
+      }
+    }
+  }
 
   NS_RELEASE(sInstance);
   sInstance = nullptr;
 }