Bug 777770 - get rid of nsVoidArray from /mailnews, r=rkent, a=rkent CLOSED TREE
authorStefan Sitter <ssitter@gmail.com>
Wed, 13 May 2015 11:09:45 -0700
changeset 26125 44917543a77bebdc40d8f84c3825c1a2abf013ce
parent 26124 dc0abd44e2504c9924496a3b7f20c171c181281e
child 26126 7af2eea538ce6d0f465328b95bc0fb652d397999
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs777770
Bug 777770 - get rid of nsVoidArray from /mailnews, r=rkent, a=rkent CLOSED TREE
mailnews/addrbook/src/nsAbBSDirectory.cpp
mailnews/addrbook/src/nsAbLDAPChangeLogData.h
mailnews/addrbook/src/nsAbView.cpp
mailnews/addrbook/src/nsAbView.h
mailnews/addrbook/src/nsDirPrefs.cpp
mailnews/addrbook/src/nsDirPrefs.h
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgDBView.h
mailnews/imap/src/nsIMAPBodyShell.cpp
mailnews/imap/src/nsIMAPBodyShell.h
mailnews/imap/src/nsIMAPNamespace.cpp
mailnews/imap/src/nsIMAPNamespace.h
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapIncomingServer.h
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapProtocol.h
mailnews/imap/src/nsImapSearchResults.cpp
mailnews/imap/src/nsImapSearchResults.h
mailnews/import/eudora/src/nsEudoraAddress.cpp
mailnews/import/eudora/src/nsEudoraAddress.h
mailnews/import/eudora/src/nsEudoraCompose.cpp
mailnews/import/eudora/src/nsEudoraCompose.h
mailnews/import/eudora/src/nsEudoraMailbox.cpp
mailnews/import/eudora/src/nsEudoraMailbox.h
mailnews/import/oexpress/nsOEScanBoxes.cpp
mailnews/import/oexpress/nsOEScanBoxes.h
mailnews/import/outlook/src/MapiApi.cpp
mailnews/import/outlook/src/MapiApi.h
mailnews/import/src/nsImportFieldMap.cpp
mailnews/import/src/nsImportFieldMap.h
mailnews/local/public/nsIPop3Protocol.idl
mailnews/local/src/nsParseMailbox.cpp
mailnews/local/src/nsParseMailbox.h
mailnews/local/src/nsPop3IncomingServer.cpp
mailnews/local/src/nsPop3IncomingServer.h
mailnews/local/src/nsPop3Protocol.cpp
mailnews/local/src/nsPop3Protocol.h
mailnews/mime/emitters/nsMimeBaseEmitter.cpp
mailnews/mime/emitters/nsMimeBaseEmitter.h
mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
mailnews/mime/src/mimei.cpp
--- a/mailnews/addrbook/src/nsAbBSDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbBSDirectory.cpp
@@ -10,17 +10,16 @@
 #include "nsAbBaseCID.h"
 #include "nsAddrDatabase.h"
 #include "nsIAbManager.h"
 #include "nsIAbMDBDirectory.h"
 #include "nsServiceManagerUtils.h"
 #include "nsAbDirFactoryService.h"
 #include "nsAbMDBDirFactory.h"
 #include "nsArrayEnumerator.h"
-#include "nsVoidArray.h"
 
 #include "nsCRTGlue.h"
 
 nsAbBSDirectory::nsAbBSDirectory()
 : mInitialized(false)
 , mServers(13)
 {
 }
@@ -103,24 +102,24 @@ nsresult nsAbBSDirectory::EnsureInitiali
   if (mInitialized)
     return NS_OK;
 
   nsresult rv;
   nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = 
     do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv);
   NS_ENSURE_SUCCESS (rv, rv);
     
-  nsVoidArray *directories = DIR_GetDirectories();
+  nsTArray<DIR_Server*> *directories = DIR_GetDirectories();
   if (!directories)
     return NS_ERROR_FAILURE;
     
-  int32_t count = directories->Count();
+  int32_t count = directories->Length();
   for (int32_t i = 0; i < count; i++)
   {
-    DIR_Server *server = (DIR_Server *)(directories->ElementAt(i));
+    DIR_Server *server = directories->ElementAt(i);
       
     // if this is a 4.x, local .na2 addressbook (PABDirectory)
     // we must skip it.
     // mozilla can't handle 4.x .na2 addressbooks
     // note, the filename might be na2 for 4.x LDAP directories
     // (we used the .na2 file for replication), and we don't want to skip
     // those.  see bug #127007
     uint32_t fileNameLen = strlen(server->fileName);
--- a/mailnews/addrbook/src/nsAbLDAPChangeLogData.h
+++ b/mailnews/addrbook/src/nsAbLDAPChangeLogData.h
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsAbLDAPChangeLogData_h__
 #define nsAbLDAPChangeLogData_h__
 
 #include "mozilla/Attributes.h"
 #include "nsAbLDAPReplicationData.h"
 #include "nsAbLDAPChangeLogQuery.h"
-#include "nsVoidArray.h"
 
 typedef struct {
   nsCString     changeLogDN;
   int32_t       firstChangeNumber;
   int32_t       lastChangeNumber;
   nsCString     dataVersion;
 } RootDSEChangeLogEntry;
 
--- a/mailnews/addrbook/src/nsAbView.cpp
+++ b/mailnews/addrbook/src/nsAbView.cpp
@@ -82,17 +82,17 @@ NS_IMETHODIMP nsAbView::ClearView()
     nsCOMPtr<nsIAbManager> abManager(do_GetService(NS_ABMANAGER_CONTRACTID,
                                                    &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = abManager->RemoveAddressBookListener(this);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  int32_t i = mCards.Count();
+  int32_t i = mCards.Length();
   while(i-- > 0)
     NS_ASSERTION(NS_SUCCEEDED(RemoveCardAt(i)), "remove card failed\n");
 
   return NS_OK;
 }
 
 nsresult nsAbView::RemoveCardAt(int32_t row)
 {
@@ -108,17 +108,17 @@ nsresult nsAbView::RemoveCardAt(int32_t 
   
   // This needs to happen after we remove the card, as RowCountChanged() will call GetRowCount()
   if (mTree) {
     rv = mTree->RowCountChanged(row, -1);
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
   if (mAbViewListener && !mSuppressCountChange) {
-    rv = mAbViewListener->OnCountChanged(mCards.Count());
+    rv = mAbViewListener->OnCountChanged(mCards.Length());
     NS_ENSURE_SUCCESS(rv,rv);
   }
   return NS_OK;
 }
 
 nsresult nsAbView::SetGeneratedNameFormatFromPrefs()
 {
   nsresult rv;
@@ -174,17 +174,17 @@ NS_IMETHODIMP nsAbView::SetView(nsIAbDir
   if (mTree)
   {
     // Try and speed deletion of old cards by disconnecting the tree from us.
     mTreeSelection->ClearSelection();
     mTree->SetView(nullptr);
   }
 
   // Clear out old cards
-  int32_t i = mCards.Count();
+  int32_t i = mCards.Length();
   while(i-- > 0)
   {
     rv = RemoveCardAt(i);
     NS_ASSERTION(NS_SUCCEEDED(rv), "remove card failed\n");
   }
 
   // We replace all cards so any sorting is no longer valid.
   mSortColumn.AssignLiteral("");
@@ -243,18 +243,18 @@ NS_IMETHODIMP nsAbView::SetView(nsIAbDir
   }
 
   NS_NAMED_LITERAL_STRING(generatedNameColumnId, GENERATED_NAME_COLUMN_ID);
 
   // See if the persisted sortColumn is valid.
   // It may not be, if you migrated from older versions, or switched between
   // a mozilla build and a commercial build, which have different columns.
   nsAutoString actualSortColumn;
-  if (!generatedNameColumnId.Equals(aSortColumn) && mCards.Count()) {
-    nsIAbCard *card = ((AbCard *)(mCards.ElementAt(0)))->card;
+  if (!generatedNameColumnId.Equals(aSortColumn) && mCards.Length()) {
+    nsIAbCard *card = mCards.ElementAt(0)->card;
     nsString value;
     // XXX todo
     // Need to check if _Generic is valid.  GetCardValue() will always return NS_OK for _Generic
     // We're going to have to ask mDirectory if it is.
     // It might not be.  example:  _ScreenName is valid in Netscape, but not Mozilla.
     rv = GetCardValue(card, PromiseFlatString(aSortColumn).get(), value);
     if (NS_FAILED(rv))
       actualSortColumn = generatedNameColumnId;
@@ -264,17 +264,17 @@ NS_IMETHODIMP nsAbView::SetView(nsIAbDir
   else
     actualSortColumn = aSortColumn;
 
   rv = SortBy(actualSortColumn.get(), PromiseFlatString(aSortDirection).get(), false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mAbViewListener = aAbViewListener;
   if (mAbViewListener && !mSuppressCountChange) {
-    rv = mAbViewListener->OnCountChanged(mCards.Count());
+    rv = mAbViewListener->OnCountChanged(mCards.Length());
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   aResult = actualSortColumn;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetDirectory(nsIAbDirectory **aDirectory)
@@ -313,28 +313,28 @@ nsresult nsAbView::EnumerateCards()
         NS_IF_ADDREF(abcard->card);
 
         // XXX todo
         // Would it be better to do an insertion sort, than append and sort?
         // XXX todo
         // If we knew how many cards there was going to be
         // we could allocate an array of the size,
         // instead of growing and copying as we append.
-        DebugOnly<bool> didAppend = mCards.AppendElement((void *)abcard);
+        DebugOnly<bool> didAppend = mCards.AppendElement(abcard);
         NS_ASSERTION(didAppend, "failed to append card");
       }
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetRowCount(int32_t *aRowCount)
 {
-  *aRowCount = mCards.Count();
+  *aRowCount = mCards.Length();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetSelection(nsITreeSelection * *aSelection)
 {
   NS_IF_ADDREF(*aSelection = mTreeSelection);
   return NS_OK;
 }
@@ -349,26 +349,26 @@ NS_IMETHODIMP nsAbView::GetRowProperties
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP nsAbView::GetCellProperties(int32_t row, nsITreeColumn* col, nsAString& properties)
 {
   NS_ENSURE_TRUE(row >= 0, NS_ERROR_UNEXPECTED);
 
-  if (mCards.Count() <= row)
+  if (mCards.Length() <= row)
     return NS_OK;
 
   const char16_t* colID;
   col->GetIdConst(&colID);
   // "G" == "GeneratedName"
   if (colID[0] != char16_t('G'))
     return NS_OK;
 
-  nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
+  nsIAbCard *card = mCards.ElementAt(row)->card;
 
   bool isMailList;
   nsresult rv = card->GetIsMailList(&isMailList);
   NS_ENSURE_SUCCESS(rv,rv);
 
   if (isMailList)
     properties.AssignLiteral("MailList");
 
@@ -520,19 +520,19 @@ nsresult nsAbView::RefreshTree()
     SelectionChanged();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP nsAbView::GetCellText(int32_t row, nsITreeColumn* col, nsAString& _retval)
 {
-  NS_ENSURE_TRUE(row >= 0 && row < mCards.Count(), NS_ERROR_UNEXPECTED);
+  NS_ENSURE_TRUE(row >= 0 && row < mCards.Length(), NS_ERROR_UNEXPECTED);
 
-  nsIAbCard *card = ((AbCard *)(mCards.ElementAt(row)))->card;
+  nsIAbCard *card = mCards.ElementAt(row)->card;
   const char16_t* colID;
   col->GetIdConst(&colID);
   return GetCardValue(card, colID, _retval);
 }
 
 NS_IMETHODIMP nsAbView::SetTree(nsITreeBoxObject *tree)
 {
   mTree = tree;
@@ -607,23 +607,23 @@ NS_IMETHODIMP nsAbView::PerformActionOnR
 NS_IMETHODIMP nsAbView::PerformActionOnCell(const char16_t *action, int32_t row, nsITreeColumn* col)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP nsAbView::GetCardFromRow(int32_t row, nsIAbCard **aCard)
 {
   *aCard = nullptr;  
-  if (mCards.Count() <= row) {
+  if (mCards.Length() <= row) {
     return NS_OK;
   }
 
   NS_ENSURE_TRUE(row >= 0, NS_ERROR_UNEXPECTED);
 
-  AbCard *a = ((AbCard *)(mCards.ElementAt(row)));
+  AbCard *a = mCards.ElementAt(row);
   if (!a)
       return NS_OK;
 
   NS_IF_ADDREF(*aCard = a->card);
   return NS_OK;
 }
 
 #define DESCENDING_SORT_FACTOR -1
@@ -674,21 +674,36 @@ static void SetSortClosure(const char16_
     closure->factor = DESCENDING_SORT_FACTOR;
   else 
     closure->factor = ASCENDING_SORT_FACTOR;
 
   closure->abView = abView;
   return;
 }
 
+class CardComparator {
+  private:
+    SortClosure *m_closure;
+
+  public:
+    void SetClosure(SortClosure *closure) { m_closure = closure; };
+    /** @return True if the elements are equals; false otherise. */
+    bool Equals(const AbCard* a, const AbCard* b) const {
+      return inplaceSortCallback(a, b, m_closure) == 0;
+    }
+    bool LessThan(const AbCard* a, const AbCard* b) const{
+      return inplaceSortCallback(a, b, m_closure) < 0;
+    }
+};
+
 NS_IMETHODIMP nsAbView::SortBy(const char16_t *colID, const char16_t *sortDir, bool aResort = false)
 {
   nsresult rv;
 
-  int32_t count = mCards.Count();
+  int32_t count = mCards.Length();
 
   nsAutoString sortColumn;
   if (!colID)
     sortColumn = NS_LITERAL_STRING(GENERATED_NAME_COLUMN_ID);  // default sort column
   else
     sortColumn = colID;
 
   nsAutoString sortDirection;
@@ -702,28 +717,28 @@ NS_IMETHODIMP nsAbView::SortBy(const cha
       // If sortColumn and sortDirection are identical since the last call, do nothing.
       return NS_OK;
     } else {
       // If we are sorting by how we are already sorted,
       // and just the sort direction changes, just reverse.
       int32_t halfPoint = count / 2;
       for (int32_t i = 0; i < halfPoint; i++) {
         // Swap the elements.
-        void *ptr1 = mCards.ElementAt(i);
-        void *ptr2 = mCards.ElementAt(count - i - 1);
-        mCards.ReplaceElementAt(ptr2, i);
-        mCards.ReplaceElementAt(ptr1, count - i - 1);
+        AbCard *ptr1 = mCards.ElementAt(i);
+        AbCard *ptr2 = mCards.ElementAt(count - i - 1);
+        mCards.ReplaceElementAt(i, ptr2);
+        mCards.ReplaceElementAt(count - i - 1, ptr1);
       }
       mSortDirection = sortDir;
     }
   }
   else {
     // Generate collation keys
     for (int32_t i = 0; i < count; i++) {
-      AbCard *abcard = (AbCard *)(mCards.ElementAt(i));
+      AbCard *abcard = mCards.ElementAt(i);
 
       rv = GenerateCollationKeysForCard(sortColumn.get(), abcard);
       NS_ENSURE_SUCCESS(rv,rv);
     }
 
     // We need to do full sort.
     SortClosure closure;
     SetSortClosure(sortColumn.get(), sortDirection.get(), this, &closure);
@@ -743,18 +758,20 @@ NS_IMETHODIMP nsAbView::SortBy(const cha
       NS_ENSURE_SUCCESS(rv,rv);
 
       if (currentIndex != -1) {
         rv = GetCardFromRow(currentIndex, getter_AddRefs(indexCard));
         NS_ENSURE_SUCCESS(rv,rv);
       }
     }
 
-    mCards.Sort(inplaceSortCallback, (void *)(&closure));
-    
+    CardComparator cardComparator;
+    cardComparator.SetClosure(&closure);
+    mCards.Sort(cardComparator);
+
     rv = ReselectCards(selectedCards, indexCard);
     NS_ENSURE_SUCCESS(rv, rv);
 
     mSortColumn = sortColumn;
     mSortDirection = sortDirection;
   }
 
   rv = InvalidateTree(ALL_ROWS);
@@ -905,50 +922,50 @@ NS_IMETHODIMP nsAbView::Observe(nsISuppo
 }
 
 nsresult nsAbView::AddCard(AbCard *abcard, bool selectCardAfterAdding, int32_t *index)
 {
   nsresult rv = NS_OK;
   NS_ENSURE_ARG_POINTER(abcard);
   
   *index = FindIndexForInsert(abcard);
-  mCards.InsertElementAt((void *)abcard, *index);
+  mCards.InsertElementAt(*index, abcard);
 
   // This needs to happen after we insert the card, as RowCountChanged() will call GetRowCount()
   if (mTree)
     rv = mTree->RowCountChanged(*index, 1);
 
   // Checking for mTree here works around core bug 399227
   if (selectCardAfterAdding && mTreeSelection && mTree) {
     mTreeSelection->SetCurrentIndex(*index);
     mTreeSelection->RangedSelect(*index, *index, false /* augment */);
   }
 
   if (mAbViewListener && !mSuppressCountChange) {
-    rv = mAbViewListener->OnCountChanged(mCards.Count());
+    rv = mAbViewListener->OnCountChanged(mCards.Length());
     NS_ENSURE_SUCCESS(rv,rv);
   }
 
   return rv;
 }
 
 int32_t nsAbView::FindIndexForInsert(AbCard *abcard)
 {
-  int32_t count = mCards.Count();
+  int32_t count = mCards.Length();
   int32_t i;
 
   void *item = (void *)abcard;
   
   SortClosure closure;
   SetSortClosure(mSortColumn.get(), mSortDirection.get(), this, &closure);
   
   // XXX todo
   // Make this a binary search
   for (i=0; i < count; i++) {
-    void *current = mCards.ElementAt(i);
+    void *current = (void *)mCards.ElementAt(i);
     int32_t value = inplaceSortCallback(item, current, (void *)(&closure));
     // XXX Fix me, this is not right for both ascending and descending
     if (value <= 0) 
       break;
   }
   return i;
 }
 
@@ -1000,34 +1017,34 @@ nsresult nsAbView::RemoveCardAndSelectNe
         if (index == selectedIndex)
           selectNextCard = true;
       }
 
       rv = RemoveCardAt(index);
       NS_ENSURE_SUCCESS(rv,rv);
 
       if (selectNextCard) {
-      int32_t count = mCards.Count();
+      int32_t count = mCards.Length();
       if (count && mTreeSelection) {
         // If we deleted the last card, adjust so we select the new "last" card
         if (index >= (count - 1)) {
           index = count -1;
         }
         mTreeSelection->SetCurrentIndex(index);
         mTreeSelection->RangedSelect(index, index, false /* augment */);
       }
     }
   }
   }
   return rv;
 }
 
 int32_t nsAbView::FindIndexForCard(nsIAbCard *card)
 {
-  int32_t count = mCards.Count();
+  int32_t count = mCards.Length();
   int32_t i;
  
   // You can't implement the binary search here, as all you have is the nsIAbCard
   // you might be here because one of the card properties has changed, and that property
   // could be the collation key.
   for (i=0; i < count; i++) {
     AbCard *abcard = (AbCard*) (mCards.ElementAt(i));
     bool equals;
@@ -1211,17 +1228,17 @@ nsresult nsAbView::GetSelectedCards(nsCO
     return NS_OK;
 
   for (int32_t i = 0; i < selectionCount; i++)
   {
     int32_t startRange;
     int32_t endRange;
     rv = mTreeSelection->GetRangeAt(i, &startRange, &endRange);
     NS_ENSURE_SUCCESS(rv, NS_OK); 
-    int32_t totalCards = mCards.Count();
+    int32_t totalCards = mCards.Length();
     if (startRange >= 0 && startRange < totalCards)
     {
       for (int32_t rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < totalCards; rangeIndex++) {
         nsCOMPtr<nsIAbCard> abCard;
         rv = GetCardFromRow(rangeIndex, getter_AddRefs(abCard));
         NS_ENSURE_SUCCESS(rv,rv);
         
         rv = aSelectedCards->AppendElement(abCard, false);
@@ -1277,17 +1294,17 @@ NS_IMETHODIMP nsAbView::SwapFirstNameLas
   }
 
   for (int32_t i = 0; i < selectionCount; i++)
   {
     int32_t startRange;
     int32_t endRange;
     rv = mTreeSelection->GetRangeAt(i, &startRange, &endRange);
     NS_ENSURE_SUCCESS(rv, NS_OK); 
-    int32_t totalCards = mCards.Count();
+    int32_t totalCards = mCards.Length();
     if (startRange >= 0 && startRange < totalCards)
     {
       for (int32_t rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < totalCards; rangeIndex++) {
         nsCOMPtr<nsIAbCard> abCard;
         rv = GetCardFromRow(rangeIndex, getter_AddRefs(abCard));
         NS_ENSURE_SUCCESS(rv, rv);
 
         // Swap FN/LN
--- a/mailnews/addrbook/src/nsAbView.h
+++ b/mailnews/addrbook/src/nsAbView.h
@@ -7,17 +7,17 @@
 #define _nsAbView_H_
 
 #include "nsISupports.h"
 #include "nsStringGlue.h"
 #include "nsIAbView.h"
 #include "nsITreeView.h"
 #include "nsITreeBoxObject.h"
 #include "nsITreeSelection.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsIAbDirectory.h"
 #include "nsIAtom.h"
 #include "nsICollation.h"
 #include "nsIAbListener.h"
 #include "nsIObserver.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
@@ -61,17 +61,17 @@ private:
   nsresult GetSelectedCards(nsCOMPtr<nsIMutableArray> &aSelectedCards);
   nsresult ReselectCards(nsIArray *aCards, nsIAbCard *aIndexCard);
   nsresult GetCardValue(nsIAbCard *card, const char16_t *colID, nsAString &_retval);
   nsresult RefreshTree();
 
   nsCOMPtr<nsITreeBoxObject> mTree;
   nsCOMPtr<nsITreeSelection> mTreeSelection;
   nsCOMPtr <nsIAbDirectory> mDirectory;
-  nsVoidArray mCards;
+  nsTArray<AbCard*> mCards;
   nsString mSortColumn;
   nsString mSortDirection;
   nsCOMPtr<nsICollation> mCollationKeyGenerator;
   nsCOMPtr<nsIAbViewListener> mAbViewListener;
   nsCOMPtr<nsIStringBundle> mABBundle;
 
   bool mInitialized;
   bool mIsAllDirectoryRootView;
--- a/mailnews/addrbook/src/nsDirPrefs.cpp
+++ b/mailnews/addrbook/src/nsDirPrefs.cpp
@@ -5,17 +5,17 @@
 
 /* directory server preferences (used to be dirprefs.c in 4.x) */
 
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsDirPrefs.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIObserver.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsServiceManagerUtils.h"
 #include "nsMemory.h"
 #include "nsIAddrDatabase.h"
 #include "nsAbBaseCID.h"
 #include "nsIAbManager.h"
 #include "nsIFile.h"
 #include "nsWeakReference.h"
 #include "nsIAbMDBDirectory.h"
@@ -43,38 +43,38 @@ static bool dir_IsServerDeleted(DIR_Serv
 static char *DIR_GetStringPref(const char *prefRoot, const char *prefLeaf, const char *defaultValue);
 static int32_t DIR_GetIntPref(const char *prefRoot, const char *prefLeaf, int32_t defaultValue);
 static char *DIR_GetLocalizedStringPref(const char *prefRoot, const char *prefLeaf);
 
 static char * dir_ConvertDescriptionToPrefName(DIR_Server * server);
 
 void DIR_SetFileName(char** filename, const char* leafName);
 static void DIR_SetIntPref(const char *prefRoot, const char *prefLeaf, int32_t value, int32_t defaultValue);
-static DIR_Server *dir_MatchServerPrefToServer(nsVoidArray *wholeList, const char *pref);
-static bool dir_ValidateAndAddNewServer(nsVoidArray *wholeList, const char *fullprefname);
-static void DIR_DeleteServerList(nsVoidArray *wholeList);
+static DIR_Server *dir_MatchServerPrefToServer(nsTArray<DIR_Server*> *wholeList, const char *pref);
+static bool dir_ValidateAndAddNewServer(nsTArray<DIR_Server*> *wholeList, const char *fullprefname);
+static void DIR_DeleteServerList(nsTArray<DIR_Server*> *wholeList);
 
 static char *dir_CreateServerPrefName(DIR_Server *server);
 static void DIR_GetPrefsForOneServer(DIR_Server *server);
 
 static void DIR_InitServer(DIR_Server *server, DirectoryType dirType = (DirectoryType)0);
 static DIR_PrefId  DIR_AtomizePrefName(const char *prefname);
 
 const int32_t DIR_POS_APPEND = -1;
 const int32_t DIR_POS_DELETE = -2;
-static bool DIR_SetServerPosition(nsVoidArray *wholeList, DIR_Server *server, int32_t position);
+static bool DIR_SetServerPosition(nsTArray<DIR_Server*> *wholeList, DIR_Server *server, int32_t position);
 
 /* These two routines should be called to initialize and save 
  * directory preferences from the XP Java Script preferences
  */
-static nsresult DIR_GetServerPreferences(nsVoidArray** list);
-static void DIR_SaveServerPreferences(nsVoidArray *wholeList);
+static nsresult DIR_GetServerPreferences(nsTArray<DIR_Server*>** list);
+static void DIR_SaveServerPreferences(nsTArray<DIR_Server*> *wholeList);
 
 static int32_t dir_UserId = 0;
-nsVoidArray *dir_ServerList = nullptr;
+nsTArray<DIR_Server*> *dir_ServerList = nullptr;
 
 /*****************************************************************************
  * Functions for creating the new back end managed DIR_Server list.
  */
 class DirPrefObserver final : public nsSupportsWeakReference,
                               public nsIObserver
 {
 public:
@@ -174,33 +174,33 @@ static nsresult DIR_GetDirServers()
       NS_ADDREF(prefObserver);
 
       pbi->AddObserver(PREF_LDAP_SERVER_TREE_NAME, prefObserver, true);
     }
   }
   return rv;
 }
 
-nsVoidArray* DIR_GetDirectories()
+nsTArray<DIR_Server*>* DIR_GetDirectories()
 {
     if (!dir_ServerList)
         DIR_GetDirServers();
   return dir_ServerList;
 }
 
 DIR_Server* DIR_GetServerFromList(const char* prefName)
 {
   DIR_Server* result = nullptr;
 
   if (!dir_ServerList)
     DIR_GetDirServers();
 
   if (dir_ServerList)
   {
-    int32_t count = dir_ServerList->Count();
+    int32_t count = dir_ServerList->Length();
     int32_t i;
     for (i = 0; i < count; ++i)
     {
       DIR_Server *server = (DIR_Server *)dir_ServerList->ElementAt(i);
 
       if (server && strcmp(server->prefName, prefName) == 0)
       {
         result = server;
@@ -240,17 +240,17 @@ nsresult DIR_ShutDown()  /* FEs should c
   
   return NS_OK;
 }
 
 nsresult DIR_ContainsServer(DIR_Server* pServer, bool *hasDir)
 {
   if (dir_ServerList)
   {
-    int32_t count = dir_ServerList->Count();
+    int32_t count = dir_ServerList->Length();
     int32_t i;
     for (i = 0; i < count; i++)
     {
       DIR_Server* server = (DIR_Server *)(dir_ServerList->ElementAt(i));
       if (server == pServer)
       {
         *hasDir = true;
         return NS_OK;
@@ -333,30 +333,30 @@ static void DIR_InitServer(DIR_Server *s
  * are supported:
  *   DIR_POS_APPEND - Appends the server to the end of the list.  If the server
  *                    is already in the list, does nothing.
  *   DIR_POS_DELETE - Deletes the given server from the list.  Note that this
  *                    does not cause the server structure to be freed.
  *
  * Returns true if the server list was re-sorted.
  */
-static bool DIR_SetServerPosition(nsVoidArray *wholeList, DIR_Server *server, int32_t position)
+static bool DIR_SetServerPosition(nsTArray<DIR_Server*> *wholeList, DIR_Server *server, int32_t position)
  {
    NS_ENSURE_TRUE(wholeList, false);
 
    int32_t    i, count, num;
    bool       resort = false;
    DIR_Server *s=nullptr;
    
    switch (position) {
    case DIR_POS_APPEND:
    /* Do nothing if the request is to append a server that is already
      * in the list.
      */
-     count = wholeList->Count();
+     count = wholeList->Length();
      for (i= 0; i < count; i++)
      {
        if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
          if (s == server)
            return false;
      }
      /* In general, if there are any servers already in the list, set the
      * position to the position of the last server plus one.  If there
@@ -394,33 +394,33 @@ static bool DIR_SetServerPosition(nsVoid
      /* If the server is in the server list, remove it.
      */
      num = wholeList->IndexOf(server);
      if (num >= 0)
      {
      /* The list does not need to be re-sorted if the server is the
      * last one in the list.
        */
-       count = wholeList->Count();
+       count = wholeList->Length();
        if (num == count - 1)
        {
          wholeList->RemoveElementAt(num);
        }
        else
        {
          resort = true;
          wholeList->RemoveElement(server);
        }
      }
      break;
      
    default:
    /* See if the server is already in the list.
      */
-     count = wholeList->Count();
+     count = wholeList->Length();
      for (i= 0; i < count; i++)
      {
        if  ((s = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
          if (s == server)
            break;
      }
      
      /* If the server is not in the list, add it to the beginning and re-sort.
@@ -455,21 +455,21 @@ static bool DIR_SetServerPosition(nsVoid
  * DIR_Server Callback Notification Functions
  */
 
 /* dir_matchServerPrefToServer
  *
  * This function finds the DIR_Server in the unified DIR_Server list to which
  * the given preference string belongs.
  */
-static DIR_Server *dir_MatchServerPrefToServer(nsVoidArray *wholeList, const char *pref)
+static DIR_Server *dir_MatchServerPrefToServer(nsTArray<DIR_Server*> *wholeList, const char *pref)
 {
   DIR_Server *server;
 
-  int32_t count = wholeList->Count();
+  int32_t count = wholeList->Length();
   int32_t i;
   for (i = 0; i < count; i++)
   {
     if ((server = (DIR_Server *)wholeList->ElementAt(i)) != nullptr)
     {
       if (server->prefName && PL_strstr(pref, server->prefName) == pref)
       {
         char c = pref[PL_strlen(server->prefName)];
@@ -482,17 +482,17 @@ static DIR_Server *dir_MatchServerPrefTo
 }
 
 /* dir_ValidateAndAddNewServer
  *
  * This function verifies that the position, serverName and description values
  * are set for the given prefName.  If they are then it adds the server to the
  * unified server list.
  */
-static bool dir_ValidateAndAddNewServer(nsVoidArray *wholeList, const char *fullprefname)
+static bool dir_ValidateAndAddNewServer(nsTArray<DIR_Server*> *wholeList, const char *fullprefname)
 {
   bool rc = false;
 
   const char *endname = PL_strchr(&fullprefname[PL_strlen(PREF_LDAP_SERVER_TREE_NAME) + 1], '.');
   if (endname)
   {
     char *prefname = (char *)PR_Malloc(endname - fullprefname + 1);
     if (prefname)
@@ -655,34 +655,34 @@ nsresult DIR_DeleteServerFromList(DIR_Se
       if (database)  /* database exists */
       {
         database->ForceClosed();
         rv = dbPath->Remove(false);
         NS_ENSURE_SUCCESS(rv, rv);
       }
     }
 
-    nsVoidArray *dirList = DIR_GetDirectories();
+    nsTArray<DIR_Server*> *dirList = DIR_GetDirectories();
     DIR_SetServerPosition(dirList, server, DIR_POS_DELETE);
     DIR_DeleteServer(server);
 
     return SavePrefsFile();
   }
 
   return NS_ERROR_NULL_POINTER;
 }
 
-static void DIR_DeleteServerList(nsVoidArray *wholeList)
+static void DIR_DeleteServerList(nsTArray<DIR_Server*> *wholeList)
 {
   if (wholeList)
   {
     DIR_Server *server = nullptr;
   
     /* TBD: Send notifications? */
-    int32_t count = wholeList->Count();
+    int32_t count = wholeList->Length();
     int32_t i;
     for (i = count - 1; i >=0; i--)
     {
       server = (DIR_Server *)wholeList->ElementAt(i);
       if (server != nullptr)
         DIR_DeleteServer(server);
     }
     delete wholeList;
@@ -1115,24 +1115,24 @@ static void DIR_GetPrefsForOneServer(DIR
 #else
     // Fallback to the all directory root in the non-ldap enabled case.
     kMDBDirectoryRoot : kAllDirectoryRoot);
 #endif
   s.Append (server->fileName);
   server->uri = DIR_GetStringPref (prefstring, "uri", s.get ());
 }
 
-static nsresult dir_GetPrefs(nsVoidArray **list)
+static nsresult dir_GetPrefs(nsTArray<DIR_Server*> **list)
 {
     nsresult rv;
     nsCOMPtr<nsIPrefBranch> pPref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     if (NS_FAILED(rv))
         return rv;
 
-    (*list) = new nsVoidArray();
+    (*list) = new nsTArray<DIR_Server*>();
     if (!(*list))
         return NS_ERROR_OUT_OF_MEMORY;
 
     char **children;
     uint32_t prefCount;
 
     rv = dir_GetChildList(NS_LITERAL_CSTRING(PREF_LDAP_SERVER_TREE_NAME "."),
                           &prefCount, &children);
@@ -1176,45 +1176,45 @@ static nsresult dir_GetPrefs(nsVoidArray
     }
 
     NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, children);
 
     return NS_OK;
 }
 
 // I don't think we care about locked positions, etc.
-void DIR_SortServersByPosition(nsVoidArray *serverList)
+void DIR_SortServersByPosition(nsTArray<DIR_Server*> *serverList)
 {
   int i, j;
   DIR_Server *server;
   
-  int count = serverList->Count();
+  int count = serverList->Length();
   for (i = 0; i < count - 1; i++)
   {
     for (j = i + 1; j < count; j++)
     {
       if (((DIR_Server *) serverList->ElementAt(j))->position < ((DIR_Server *) serverList->ElementAt(i))->position)
       {
         server        = (DIR_Server *) serverList->ElementAt(i);
-        serverList->ReplaceElementAt(serverList->ElementAt(j), i);
-        serverList->ReplaceElementAt(server, j);
+        serverList->ReplaceElementAt(i, serverList->ElementAt(j));
+        serverList->ReplaceElementAt(j, server);
       }
     }
   }
 }
 
-static nsresult DIR_GetServerPreferences(nsVoidArray** list)
+static nsresult DIR_GetServerPreferences(nsTArray<DIR_Server*>** list)
 {
   nsresult err;
   nsCOMPtr<nsIPrefBranch> pPref(do_GetService(NS_PREFSERVICE_CONTRACTID, &err));
   if (NS_FAILED(err))
     return err;
 
   int32_t version = -1;
-  nsVoidArray *newList = nullptr;
+  nsTArray<DIR_Server*> *newList = nullptr;
   
   /* Update the ldap list version and see if there are old prefs to migrate. */
   err = pPref->GetIntPref(PREF_LDAP_VERSION_NAME, &version);
   NS_ENSURE_SUCCESS(err, err);
 
   /* Find the new-style "ldap_2.servers" tree in prefs */
   err = dir_GetPrefs(&newList);
 
@@ -1421,29 +1421,29 @@ void DIR_SavePrefsForOneServer(DIR_Serve
   DIR_SetIntPref(prefstring, "dirType", server->dirType, LDAPDirectory);
 
   if (server->dirType != PABDirectory)
     DIR_SetStringPref(prefstring, "uri", server->uri, "");
 
   server->savingServer = false;
 }
 
-static void DIR_SaveServerPreferences(nsVoidArray *wholeList)
+static void DIR_SaveServerPreferences(nsTArray<DIR_Server*> *wholeList)
 {
   if (wholeList)
   {
     nsresult rv;
     nsCOMPtr<nsIPrefBranch> pPref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); 
     if (NS_FAILED(rv)) {
       NS_WARNING("DIR_SaveServerPreferences: Failed to get the pref service\n");
       return;
     }
 
     int32_t  i;
-    int32_t  count = wholeList->Count();
+    int32_t  count = wholeList->Length();
     DIR_Server *server;
 
     for (i = 0; i < count; i++)
     {
       server = (DIR_Server *) wholeList->ElementAt(i);
       if (server)
         DIR_SavePrefsForOneServer(server);
     }
--- a/mailnews/addrbook/src/nsDirPrefs.h
+++ b/mailnews/addrbook/src/nsDirPrefs.h
@@ -6,17 +6,17 @@
 #ifndef _NSDIRPREFS_H_
 #define _NSDIRPREFS_H_
 
 //
 // XXX nsDirPrefs is being greatly reduced if not removed altogether. Directory
 // Prefs etc. should be handled via their appropriate nsAb*Directory classes.
 //
 
-class nsVoidArray;
+template <class> class nsTArray;
 
 #define kPreviousListVersion   2
 #define kCurrentListVersion    3
 #define PREF_LDAP_GLOBAL_TREE_NAME "ldap_2"
 #define PREF_LDAP_VERSION_NAME     "ldap_2.version"
 #define PREF_LDAP_SERVER_TREE_NAME "ldap_2.servers"
 
 #define kMainLdapAddressBook "ldap.mab"   /* v3 main ldap address book file */
@@ -60,17 +60,17 @@ typedef struct DIR_Server
   bool savingServer;
 } DIR_Server;
 
 /* We are developing a new model for managing DIR_Servers. In the 4.0x world, the FEs managed each list. 
 	Calls to FE_GetDirServer caused the FEs to manage and return the DIR_Server list. In our new view of the
 	world, the back end does most of the list management so we are going to have the back end create and 
 	manage the list. Replace calls to FE_GetDirServers() with DIR_GetDirServers(). */
 
-nsVoidArray* DIR_GetDirectories();
+nsTArray<DIR_Server*>* DIR_GetDirectories();
 DIR_Server* DIR_GetServerFromList(const char* prefName);
 nsresult DIR_ShutDown(void);  /* FEs should call this when the app is shutting down. It frees all DIR_Servers regardless of ref count values! */
 
 nsresult DIR_AddNewAddressBook(const nsAString &dirName,
                                const nsACString &fileName,
                                const nsACString &uri, 
                                DirectoryType dirType,
                                const nsACString &prefName,
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -44,17 +44,17 @@
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
 #include "nsAlgorithm.h"
 #include "nsIAbManager.h"
 #include "nsIAbDirectory.h"
 #include "nsIAbCard.h"
 #include "mozilla/Services.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include <algorithm>
 
 using namespace mozilla::mailnews;
 nsrefcnt nsMsgDBView::gInstanceCount  = 0;
 
 nsIAtom * nsMsgDBView::kJunkMsgAtom = nullptr;
 nsIAtom * nsMsgDBView::kNotJunkMsgAtom = nullptr;
 
@@ -4468,17 +4468,17 @@ NS_IMETHODIMP nsMsgDBView::Sort(nsMsgVie
   // If we did not obtain proper fieldType, it needs to be checked
   // because the subsequent code does not handle it very well.
   rv = GetFieldTypeAndLenForSort(sortType, &maxLen, &fieldType);
 
   // Don't sort if the field type is not supported: Bug 901948
   if (NS_FAILED(rv))
     return NS_OK;
 
-  nsVoidArray ptrs;
+  nsTArray<void*> ptrs;
   uint32_t arraySize = GetSize();
 
   if (!arraySize)
     return NS_OK;
 
   nsCOMArray<nsIMsgFolder> *folders = GetFolders();
 
   IdKey** pPtrBase = (IdKey**)PR_Malloc(arraySize * sizeof(IdKey*));
@@ -4640,20 +4640,20 @@ NS_IMETHODIMP nsMsgDBView::Sort(nsMsgVie
   FreeAll(&ptrs);
 
   m_sortValid = true;
   //m_db->SetSortInfo(sortType, sortOrder);
 
   return NS_OK;
 }
 
-void nsMsgDBView::FreeAll(nsVoidArray *ptrs)
+void nsMsgDBView::FreeAll(nsTArray<void*> *ptrs)
 {
   int32_t i;
-  int32_t count = (int32_t) ptrs->Count();
+  int32_t count = (int32_t) ptrs->Length();
   if (count == 0)
     return;
 
   for (i=(count - 1);i>=0;i--)
     PR_Free((void *) ptrs->ElementAt(i));
   ptrs->Clear();
 }
 
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -31,18 +31,16 @@
 #include "nsTArray.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsIMsgCustomColumnHandler.h"
 #include "nsAutoPtr.h"
 #include "nsIWeakReferenceUtils.h"
 #define MESSENGER_STRING_URL       "chrome://messenger/locale/messenger.properties"
 
-class nsVoidArray;
-
 typedef nsAutoTArray<nsMsgViewIndex, 1> nsMsgViewIndexArray;
 static_assert(nsMsgViewIndex(nsMsgViewIndexArray::NoIndex) ==
   nsMsgViewIndex_None, "These need to be the same value.");
 
 enum eFieldType {
     kCollationKey,
     kU32
 };
@@ -361,17 +359,17 @@ protected:
   nsresult CopyDBView(nsMsgDBView *aNewMsgDBView, nsIMessenger *aMessengerInstance, nsIMsgWindow *aMsgWindow, nsIMsgDBViewCommandUpdater *aCmdUpdater);
   void InitializeAtomsAndLiterals();
   virtual int32_t FindLevelInThread(nsIMsgDBHdr *msgHdr, nsMsgViewIndex startOfThread, nsMsgViewIndex viewIndex);
   nsresult GetImapDeleteModel(nsIMsgFolder *folder);
   nsresult UpdateDisplayMessage(nsMsgViewIndex viewPosition);
   nsresult GetDBForHeader(nsIMsgDBHdr *msgHdr, nsIMsgDatabase **db);
 
   bool AdjustReadFlag(nsIMsgDBHdr *msgHdr, uint32_t *msgFlags);
-  void FreeAll(nsVoidArray *ptrs);
+  void FreeAll(nsTArray<void*> *ptrs);
   void ClearHdrCache();
   nsTArray<nsMsgKey> m_keys;
   nsTArray<uint32_t> m_flags;
   nsTArray<uint8_t> m_levels;
   nsMsgImapDeleteModel mDeleteModel;
 
   // cache the most recently asked for header and corresponding msgKey.
   nsCOMPtr <nsIMsgDBHdr>  m_cachedHdr;
--- a/mailnews/imap/src/nsIMAPBodyShell.cpp
+++ b/mailnews/imap/src/nsIMAPBodyShell.cpp
@@ -758,19 +758,19 @@ bool nsIMAPBodypartLeaf::ShouldFetchInli
 }
 
 
 
 bool nsIMAPBodypartMultipart::IsLastTextPart(const char *partNumberString)
 {
  // iterate backwards over the parent's part list and if the part is
   // text, compare it to the part number string
-  for (int i = m_partList->Count() - 1; i >= 0; i--)
+  for (int i = m_partList->Length() - 1; i >= 0; i--)
   {
-      nsIMAPBodypart *part = (nsIMAPBodypart *)(m_partList->ElementAt(i));
+      nsIMAPBodypart *part = m_partList->ElementAt(i);
       if (!PL_strcasecmp(part->GetBodyType(), "text"))
         return !PL_strcasecmp(part->GetPartNumberString(), partNumberString);
   }
   return false;
 }
 
 bool nsIMAPBodypartLeaf::PreflightCheckAllInline(nsIMAPBodyShell *aShell)
 {
@@ -952,34 +952,34 @@ nsIMAPBodypart(partNum, parentPart)
     PR_FREEIF(m_partNumberString);
     if (!m_parentPart)
     {
       m_partNumberString = PR_smprintf("0");
     }
     else
       m_partNumberString = NS_strdup(m_parentPart->GetPartNumberString());
   }
-  m_partList = new nsVoidArray();
+  m_partList = new nsTArray<nsIMAPBodypart*>();
   m_bodyType = NS_strdup("multipart");
   if (m_partList && m_parentPart && m_bodyType)
     SetIsValid(true);
   else
     SetIsValid(false);
 }
 
 nsIMAPBodypartType nsIMAPBodypartMultipart::GetType()
 {
   return IMAP_BODY_MULTIPART;
 }
 
 nsIMAPBodypartMultipart::~nsIMAPBodypartMultipart()
 {
-  for (int i = m_partList->Count() - 1; i >= 0; i--)
+  for (int i = m_partList->Length() - 1; i >= 0; i--)
   {
-    delete (nsIMAPBodypart *)(m_partList->ElementAt(i));
+    delete m_partList->ElementAt(i);
   }
   delete m_partList;
 }
 
 void
 nsIMAPBodypartMultipart::SetBodySubType(char *bodySubType)
 {
   PR_FREEIF(m_bodySubType);
@@ -1008,22 +1008,22 @@ int32_t nsIMAPBodypartMultipart::Generat
     bool needMIMEHeader = !parentIsMessageType;  // !PL_strcasecmp(m_bodySubType, "signed") ? true : !parentIsMessageType;
     if (needMIMEHeader && !aShell->GetPseudoInterrupted())  // not a message body's type
     {
       len += GenerateMIMEHeader(aShell, stream, prefetch);
     }
     
     if (ShouldFetchInline(aShell))
     {
-      for (int i = 0; i < m_partList->Count(); i++)
+      for (int i = 0; i < m_partList->Length(); i++)
       {
         if (!aShell->GetPseudoInterrupted())
           len += GenerateBoundary(aShell, stream, prefetch, false);
         if (!aShell->GetPseudoInterrupted())
-          len += ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->Generate(aShell, stream, prefetch);
+          len += m_partList->ElementAt(i)->Generate(aShell, stream, prefetch);
       }
       if (!aShell->GetPseudoInterrupted())
         len += GenerateBoundary(aShell, stream, prefetch, true);
     }
     else
     {
       // fill in the filling within the empty part
       if (!aShell->GetPseudoInterrupted())
@@ -1082,37 +1082,37 @@ bool nsIMAPBodypartMultipart::ShouldFetc
   }
 }
 
 bool nsIMAPBodypartMultipart::PreflightCheckAllInline(nsIMAPBodyShell *aShell)
 {
   bool rv = ShouldFetchInline(aShell);
   
   int i = 0;
-  while (rv && (i < m_partList->Count()))
+  while (rv && (i < m_partList->Length()))
   {
-    rv = ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->PreflightCheckAllInline(aShell);
+    rv = m_partList->ElementAt(i)->PreflightCheckAllInline(aShell);
     i++;
   }
   
   return rv;
 }
 
 nsIMAPBodypart	*nsIMAPBodypartMultipart::FindPartWithNumber(const char *partNum)
 {
   NS_ASSERTION(partNum, "null part passed into FindPartWithNumber");
   
   // check this
   if (!PL_strcmp(partNum, m_partNumberString))
     return this;
   
   // check children
-  for (int i = m_partList->Count() - 1; i >= 0; i--)
+  for (int i = m_partList->Length() - 1; i >= 0; i--)
   {
-    nsIMAPBodypart *foundPart = ((nsIMAPBodypart *)(m_partList->ElementAt(i)))->FindPartWithNumber(partNum);
+    nsIMAPBodypart *foundPart = m_partList->ElementAt(i)->FindPartWithNumber(partNum);
     if (foundPart)
       return foundPart;
   }
   
   // not this, or any of this's children
   return NULL;
 }
 
@@ -1196,17 +1196,17 @@ imap_shell_cache_strcmp (const void *a, 
 {
   return PL_strcmp ((const char *) a, (const char *) b);
 }
 #endif
 
 nsIMAPBodyShellCache::nsIMAPBodyShellCache()
 : m_shellHash(20)
 {
-  m_shellList = new nsVoidArray();
+  m_shellList = new nsTArray<nsIMAPBodyShell*>();
 }
 
 /* static */ nsIMAPBodyShellCache *nsIMAPBodyShellCache::Create()
 {
   nsIMAPBodyShellCache *cache = new nsIMAPBodyShellCache();
   if (!cache || !cache->m_shellList)
     return NULL;
   
@@ -1219,20 +1219,20 @@ nsIMAPBodyShellCache::~nsIMAPBodyShellCa
   delete m_shellList;
 }
 
 // We'll use an LRU scheme here.
 // We will add shells in numerical order, so the
 // least recently used one will be in slot 0.
 bool nsIMAPBodyShellCache::EjectEntry()
 {
-  if (m_shellList->Count() < 1)
+  if (m_shellList->Length() < 1)
     return false;
 
-  nsIMAPBodyShell *removedShell = (nsIMAPBodyShell *) (m_shellList->ElementAt(0));
+  nsIMAPBodyShell *removedShell = m_shellList->ElementAt(0);
 
   m_shellList->RemoveElementAt(0);
   m_shellHash.Remove(removedShell->GetUID());
 
   return true;
 }
 
 void nsIMAPBodyShellCache::Clear()
@@ -1318,16 +1318,16 @@ nsIMAPMessagePartIDArray::nsIMAPMessageP
 
 nsIMAPMessagePartIDArray::~nsIMAPMessagePartIDArray()
 {
 	RemoveAndFreeAll();
 }
 
 void nsIMAPMessagePartIDArray::RemoveAndFreeAll()
 {
-    int n = Count();
+    int n = Length();
 	for (int i = 0; i < n; i++)
 	{
 		nsIMAPMessagePartID *part = GetPart(i);
 		delete part;
 	}
     Clear();
 }
--- a/mailnews/imap/src/nsIMAPBodyShell.h
+++ b/mailnews/imap/src/nsIMAPBodyShell.h
@@ -9,17 +9,17 @@ nsIMAPBodyShell and associated classes
 
 #ifndef IMAPBODY_H
 #define IMAPBODY_H
 
 #include "mozilla/Attributes.h"
 #include "nsImapCore.h"
 #include "nsStringGlue.h"
 #include "nsRefPtrHashtable.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 class nsImapProtocol;
 
 typedef enum _nsIMAPBodypartType {
 	IMAP_BODY_MESSAGE_RFC822,
 	IMAP_BODY_MESSAGE_HEADER,
 	IMAP_BODY_LEAF,
 	IMAP_BODY_MULTIPART
@@ -138,17 +138,17 @@ public:
     // Returns the part object with the given number
 	virtual nsIMAPBodypart	*FindPartWithNumber(const char *partNum
                                                 ) override;
     virtual bool IsLastTextPart(const char *partNumberString) override;
     void AppendPart(nsIMAPBodypart *part)  { m_partList->AppendElement(part); }
     void SetBodySubType(char *bodySubType);
 
 protected:
-	nsVoidArray			*m_partList;			// An ordered list of top-level body parts for this shell
+    nsTArray<nsIMAPBodypart*>  *m_partList;  // An ordered list of top-level body parts for this shell
 };
 
 
 // The name "leaf" is somewhat misleading, since a part of type message/rfc822 is technically
 // a leaf, even though it can contain other parts within it.
 class nsIMAPBodypartLeaf : public nsIMAPBodypart
 {
 public:
@@ -316,19 +316,19 @@ public:
   void Clear();
 
 protected:
   nsIMAPBodyShellCache();
   // Chooses an entry to eject;  deletes that entry;  and ejects it from the
   // cache, clearing up a new space.  Returns true if it found an entry
   // to eject, false otherwise.
   bool EjectEntry();
-  uint32_t GetSize() { return m_shellList->Count(); }
+  uint32_t GetSize() { return m_shellList->Length(); }
   uint32_t GetMaxSize() { return 20; }
-  nsVoidArray *m_shellList; // For maintenance
+  nsTArray<nsIMAPBodyShell*> *m_shellList; // For maintenance
   // For quick lookup based on UID
   nsRefPtrHashtable <nsCStringHashKey, nsIMAPBodyShell> m_shellHash;
 };
 
 // MessagePartID and MessagePartIDArray are used for pipelining prefetches.
 
 class nsIMAPMessagePartID
 {
@@ -339,24 +339,24 @@ public:
 
 
 protected:
 	const char *m_partNumberString;
 	nsIMAPeFetchFields m_fields;
 };
 
 
-class nsIMAPMessagePartIDArray : public nsVoidArray {
+class nsIMAPMessagePartIDArray : public nsTArray<nsIMAPMessagePartID*> {
 public:
 	nsIMAPMessagePartIDArray();
 	~nsIMAPMessagePartIDArray();
 
 	void				RemoveAndFreeAll();
-	int					GetNumParts() {return Count();}
+	int					GetNumParts() {return Length();}
 	nsIMAPMessagePartID	*GetPart(int i) 
 	{
-		NS_ASSERTION(i >= 0 && i < Count(), "invalid message part #");
-		return (nsIMAPMessagePartID *) ElementAt(i);
+		NS_ASSERTION(i >= 0 && i < Length(), "invalid message part #");
+		return ElementAt(i);
 	}
 };
 
 
 #endif // IMAPBODY_H
--- a/mailnews/imap/src/nsIMAPNamespace.cpp
+++ b/mailnews/imap/src/nsIMAPNamespace.cpp
@@ -66,17 +66,17 @@ nsIMAPNamespaceList *nsIMAPNamespaceList
 }
 
 nsIMAPNamespaceList::nsIMAPNamespaceList()
 {
 }
 
 int nsIMAPNamespaceList::GetNumberOfNamespaces()
 {
-	return m_NamespaceList.Count();
+	return m_NamespaceList.Length();
 }
 
 
 nsresult nsIMAPNamespaceList::InitFromString(const char *nameSpaceString, EIMAPNamespaceType nstype)
 {
 	nsresult rv = NS_OK;
 	if (nameSpaceString)
 	{
@@ -109,17 +109,17 @@ nsresult nsIMAPNamespaceList::OutputToSt
 
 	return rv;
 }
 
 
 int nsIMAPNamespaceList::GetNumberOfNamespaces(EIMAPNamespaceType type)
 {
 	int nodeIndex = 0, count = 0;
-	for (nodeIndex=m_NamespaceList.Count()-1; nodeIndex >= 0; nodeIndex--)
+	for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 	{
 		nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
 		if (nspace->GetType() == type)
 		{
 			count++;
 		}
 	}
 	return count;
@@ -129,17 +129,17 @@ int nsIMAPNamespaceList::AddNewNamespace
 {
 	// If the namespace is from the NAMESPACE response, then we should see if there
 	// are any namespaces previously set by the preferences, or the default namespace.  If so, remove these.
 
 	if (!ns->GetIsNamespaceFromPrefs())
 	{
 		int nodeIndex;
         // iterate backwards because we delete elements
-		for (nodeIndex=m_NamespaceList.Count()-1; nodeIndex >= 0; nodeIndex--)
+		for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 		{
 			nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
 			// if we find existing namespace(s) that matches the 
 			// new one, we'll just remove the old ones and let the
 			// new one get added when we've finished checking for
 			// matching namespaces or namespaces that came from prefs.
 			if (nspace &&
                             (nspace->GetIsNamespaceFromPrefs() ||
@@ -161,17 +161,17 @@ int nsIMAPNamespaceList::AddNewNamespace
 }
 
 
 // chrisf - later, fix this to know the real concept of "default" namespace of a given type
 nsIMAPNamespace *nsIMAPNamespaceList::GetDefaultNamespaceOfType(EIMAPNamespaceType type)
 {
 	nsIMAPNamespace *rv = 0, *firstOfType = 0;
 
-	int nodeIndex, count = m_NamespaceList.Count();
+	int nodeIndex, count = m_NamespaceList.Length();
 	for (nodeIndex= 0; nodeIndex < count && !rv; nodeIndex++)
 	{
 		nsIMAPNamespace *ns = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
 		if (ns->GetType() == type)
 		{
 			if (!firstOfType)
 				firstOfType = ns;
 			if (!(*(ns->GetPrefix())))
@@ -193,17 +193,17 @@ nsIMAPNamespaceList::~nsIMAPNamespaceLis
 }
 
 // ClearNamespaces removes and deletes the namespaces specified, and if there are no namespaces left,
 void nsIMAPNamespaceList::ClearNamespaces(bool deleteFromPrefsNamespaces, bool deleteServerAdvertisedNamespaces, bool reallyDelete)
 {
 	int nodeIndex;
 	
     // iterate backwards because we delete elements
-	for (nodeIndex=m_NamespaceList.Count()-1; nodeIndex >= 0; nodeIndex--)
+	for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
 	{
 		nsIMAPNamespace *ns = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
 		if (ns->GetIsNamespaceFromPrefs())
 		{
 			if (deleteFromPrefsNamespaces)
 			{
 				m_NamespaceList.RemoveElementAt(nodeIndex);
 				if (reallyDelete)
@@ -226,17 +226,17 @@ nsIMAPNamespace *nsIMAPNamespaceList::Ge
 
   // XXX really could be just ElementAt; that's why we have the assertion
   return 	(nsIMAPNamespace *) m_NamespaceList.SafeElementAt(nodeIndex);
 }
 
 nsIMAPNamespace *nsIMAPNamespaceList::GetNamespaceNumber(int nodeIndex, EIMAPNamespaceType type)
 {
   int nodeCount, count = 0;
-  for (nodeCount=m_NamespaceList.Count()-1; nodeCount >= 0; nodeCount--)
+  for (nodeCount=m_NamespaceList.Length() - 1; nodeCount >= 0; nodeCount--)
   {
     nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeCount);
     if (nspace->GetType() == type)
     {
       count++;
       if (count == nodeIndex)
         return nspace;
     }
@@ -258,17 +258,17 @@ nsIMAPNamespace *nsIMAPNamespaceList::Ge
   int lengthMatched = -1;
   int currentMatchedLength = -1;
   nsIMAPNamespace *rv = nullptr;
   int nodeIndex = 0;
   
   if (!PL_strcasecmp(boxname, "INBOX"))
     return GetDefaultNamespaceOfType(kPersonalNamespace);
   
-  for (nodeIndex=m_NamespaceList.Count()-1; nodeIndex >= 0; nodeIndex--)
+  for (nodeIndex = m_NamespaceList.Length() - 1; nodeIndex >= 0; nodeIndex--)
   {
     nsIMAPNamespace *nspace = (nsIMAPNamespace *) m_NamespaceList.ElementAt(nodeIndex);
     currentMatchedLength = nspace->MailboxMatchesNamespace(boxname);
     if (currentMatchedLength > lengthMatched)
     {
       rv = nspace;
       lengthMatched = currentMatchedLength;
     }
--- a/mailnews/imap/src/nsIMAPNamespace.h
+++ b/mailnews/imap/src/nsIMAPNamespace.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _nsIMAPNamespace_H_
 #define _nsIMAPNamespace_H_
 
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 class nsIMAPNamespace
 {
   
 public:
   nsIMAPNamespace(EIMAPNamespaceType type, const char *prefix, char delimiter, bool from_prefs);
   
   ~nsIMAPNamespace();
@@ -74,14 +74,14 @@ public:
                                                                                 const char *canonicalFolderName,
                                                                                 const char *owner,
                                                                                 EIMAPNamespaceType nsType,
                                                                                 nsIMAPNamespace **nsUsed);
 
 protected:
   nsIMAPNamespaceList();	// use CreatensIMAPNamespaceList to create one
   
-  nsVoidArray m_NamespaceList;
+  nsTArray<nsIMAPNamespace*> m_NamespaceList;
   
 };
 
 
 #endif
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -451,17 +451,17 @@ nsImapIncomingServer::GetImapConnectionA
     }
   }
   else
   {   // unable to get an imap connection to run the url; add to the url
      // queue
     nsImapProtocol::LogImapUrl("queuing url", aImapUrl);
     PR_CEnterMonitor(this);
     m_urlQueue.AppendObject(aImapUrl);
-    m_urlConsumers.AppendElement((void*)aConsumer);
+    m_urlConsumers.AppendElement(aConsumer);
     NS_IF_ADDREF(aConsumer);
     PR_CExitMonitor(this);
     // let's try running it now - maybe the connection is free now.
     bool urlRun;
     rv = LoadNextQueuedUrl(nullptr, &urlRun);
   }
 
   return rv;
--- a/mailnews/imap/src/nsImapIncomingServer.h
+++ b/mailnews/imap/src/nsImapIncomingServer.h
@@ -11,17 +11,17 @@
 #include "nsIImapIncomingServer.h"
 #include "nsMsgIncomingServer.h"
 #include "nsIImapServerSink.h"
 #include "nsIStringBundle.h"
 #include "nsISubscribableServer.h"
 #include "nsIUrlListener.h"
 #include "nsIMsgImapMailFolder.h"
 #include "nsCOMArray.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "mozilla/Mutex.h"
 
 class nsIRDFService;
 
 /* get some implementation from nsMsgIncomingServer */
 class nsImapIncomingServer : public nsMsgIncomingServer,
                              public nsIImapIncomingServer,
                              public nsIImapServerSink,
@@ -105,17 +105,17 @@ private:
   bool CheckSpecialFolder(nsIRDFService *rdf, nsCString &folderUri,
                             uint32_t folderFlag, nsCString &existingUri);
 
   nsCOMArray<nsIImapProtocol> m_connectionCache;
   nsCOMArray<nsIImapUrl> m_urlQueue;
   nsCOMPtr<nsIStringBundle>	m_stringBundle;
   nsCOMArray<nsIMsgFolder> m_subscribeFolders; // used to keep folder resources around while subscribe UI is up.
   nsCOMArray<nsIMsgImapMailFolder> m_foldersToStat; // folders to check for new mail with Status
-  nsVoidArray       m_urlConsumers;
+  nsTArray<nsISupports*> m_urlConsumers;
   eIMAPCapabilityFlags          m_capability;
   nsCString         m_manageMailAccountUrl;
   bool              m_userAuthenticated;
   bool              mDoingSubscribeDialog;
   bool              mDoingLsub;
   bool              m_shuttingDown;
 
   mozilla::Mutex mLock;
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -4973,42 +4973,42 @@ nsImapProtocol::DiscoverMailboxSpec(nsIm
           else if (GetMailboxDiscoveryStatus() == eContinueNew)
           {
             if (m_hierarchyNameState == kListingForInfoAndDiscovery &&
                 !adoptedBoxSpec->mAllocatedPathName.IsEmpty() &&
                 !(adoptedBoxSpec->mBoxFlags & kNameSpace))
             {
               // remember the info here also
               nsIMAPMailboxInfo *mb = new nsIMAPMailboxInfo(adoptedBoxSpec->mAllocatedPathName, adoptedBoxSpec->mHierarchySeparator);
-              m_listedMailboxList.AppendElement((void*) mb);
+              m_listedMailboxList.AppendElement(mb);
             }
             SetMailboxDiscoveryStatus(eContinue);
           }
         }
       }
       }
       NS_IF_RELEASE( adoptedBoxSpec);
       break;
     case kDiscoverBaseFolderInProgress:
       break;
     case kDeleteSubFoldersInProgress:
       {
         NS_ASSERTION(m_deletableChildren, "Oops .. null m_deletableChildren\n");
-        m_deletableChildren->AppendElement((void *)ToNewCString(adoptedBoxSpec->mAllocatedPathName));
+        m_deletableChildren->AppendElement(ToNewCString(adoptedBoxSpec->mAllocatedPathName));
         NS_IF_RELEASE(adoptedBoxSpec);
       }
       break;
     case kListingForInfoOnly:
       {
         //UpdateProgressWindowForUpgrade(adoptedBoxSpec->allocatedPathName);
         ProgressEventFunctionUsingNameWithString("imapDiscoveringMailbox",
           adoptedBoxSpec->mAllocatedPathName.get());
         nsIMAPMailboxInfo *mb = new nsIMAPMailboxInfo(adoptedBoxSpec->mAllocatedPathName,
                                                       adoptedBoxSpec->mHierarchySeparator);
-        m_listedMailboxList.AppendElement((void*) mb);
+        m_listedMailboxList.AppendElement(mb);
         NS_IF_RELEASE(adoptedBoxSpec);
       }
       break;
     case kDiscoveringNamespacesOnly:
       {
         NS_IF_RELEASE(adoptedBoxSpec);
       }
       break;
@@ -6398,21 +6398,21 @@ void nsImapProtocol::GetACLForFolder(con
 void nsImapProtocol::OnRefreshAllACLs()
 {
   m_hierarchyNameState = kListingForInfoOnly;
   nsIMAPMailboxInfo *mb = NULL;
 
   // This will fill in the list
   List("*", true);
 
-  int32_t total = m_listedMailboxList.Count(), count = 0;
+  int32_t total = m_listedMailboxList.Length(), count = 0;
   GetServerStateParser().SetReportingErrors(false);
   for (int32_t i = 0; i < total; i++)
   {
-    mb = (nsIMAPMailboxInfo *) m_listedMailboxList.ElementAt(i);
+    mb = m_listedMailboxList.ElementAt(i);
     if (mb) // paranoia
     {
       char *onlineName = nullptr;
       m_runningUrl->AllocateServerPath(PromiseFlatCString(mb->GetMailboxName()).get(), mb->GetDelimiter(), &onlineName);
       if (onlineName)
       {
         RefreshACLForFolder(onlineName);
         NS_Free(onlineName);
@@ -6728,17 +6728,17 @@ bool nsImapProtocol::RenameMailboxRespec
   return (rv);
 }
 
 bool nsImapProtocol::RenameHierarchyByHand(const char *oldParentMailboxName,
                                              const char *newParentMailboxName)
 {
   bool renameSucceeded = true;
     char onlineDirSeparator = kOnlineHierarchySeparatorUnknown;
-  m_deletableChildren = new nsVoidArray();
+  m_deletableChildren = new nsTArray<char*>();
 
   bool nonHierarchicalRename =
         ((GetServerStateParser().GetCapabilityFlag() & kNoHierarchyRename)
          || MailboxIsNoSelectMailbox(oldParentMailboxName));
 
   if (m_deletableChildren)
   {
     m_hierarchyNameState = kDeleteSubFoldersInProgress;
@@ -6769,17 +6769,17 @@ bool nsImapProtocol::RenameHierarchyByHa
     }
     m_hierarchyNameState = kNoOperationInProgress;
 
     if (GetServerStateParser().LastCommandSuccessful())
       renameSucceeded = // rename this, and move subscriptions
                 RenameMailboxRespectingSubscriptions(oldParentMailboxName,
                                                      newParentMailboxName, true);
 
-    int32_t numberToDelete = m_deletableChildren->Count();
+    int32_t numberToDelete = m_deletableChildren->Length();
         int32_t childIndex;
 
     for (childIndex = 0;
              (childIndex < numberToDelete) && renameSucceeded; childIndex++)
     {
       // the imap parser has already converted to a non UTF7 string in the canonical
       // format so convert it back
         char *currentName = (char *) m_deletableChildren->ElementAt(childIndex);
@@ -6810,17 +6810,17 @@ bool nsImapProtocol::RenameHierarchyByHa
   }
 
   return renameSucceeded;
 }
 
 bool nsImapProtocol::DeleteSubFolders(const char* selectedMailbox, bool &aDeleteSelf)
 {
   bool deleteSucceeded = true;
-  m_deletableChildren = new nsVoidArray();
+  m_deletableChildren = new nsTArray<char*>();
 
   if (m_deletableChildren)
   {
     bool folderDeleted = false;
 
     m_hierarchyNameState = kDeleteSubFoldersInProgress;
         nsCString pattern(selectedMailbox);
         char onlineDirSeparator = kOnlineHierarchySeparatorUnknown;
@@ -6833,17 +6833,17 @@ bool nsImapProtocol::DeleteSubFolders(co
       List(pattern.get(), false);
     }
     m_hierarchyNameState = kNoOperationInProgress;
 
     // this should be a short list so perform a sequential search for the
     // longest name mailbox.  Deleting the longest first will hopefully
         // prevent the server from having problems about deleting parents
         // ** jt - why? I don't understand this.
-    int32_t numberToDelete = m_deletableChildren->Count();
+    int32_t numberToDelete = m_deletableChildren->Length();
     int32_t outerIndex, innerIndex;
 
     // intelligently decide if myself(either plain format or following the dir-separator)
     // is in the sub-folder list
     bool folderInSubfolderList = false; // For Performance
     char *selectedMailboxDir = nullptr;
     {
         int32_t length = strlen(selectedMailbox);
@@ -6851,36 +6851,35 @@ bool nsImapProtocol::DeleteSubFolders(co
         if( selectedMailboxDir )    // only do the intelligent test if there is enough memory
         {
             strcpy(selectedMailboxDir, selectedMailbox);
             selectedMailboxDir[length] = onlineDirSeparator;
             selectedMailboxDir[length+1] = '\0';
             int32_t i;
             for( i=0; i<numberToDelete && !folderInSubfolderList; i++ )
             {
-                char *currentName = (char *) m_deletableChildren->ElementAt(i);
+                char *currentName = m_deletableChildren->ElementAt(i);
                 if( !strcmp(currentName, selectedMailbox) || !strcmp(currentName, selectedMailboxDir) )
                     folderInSubfolderList = true;
             }
         }
     }
 
     deleteSucceeded = GetServerStateParser().LastCommandSuccessful();
     for (outerIndex = 0;
          (outerIndex < numberToDelete) && deleteSucceeded;
          outerIndex++)
     {
         char* longestName = nullptr;
         int32_t longestIndex = 0; // fix bogus warning by initializing
         for (innerIndex = 0;
-             innerIndex < m_deletableChildren->Count();
+             innerIndex < m_deletableChildren->Length();
              innerIndex++)
         {
-            char *currentName =
-                (char *) m_deletableChildren->ElementAt(innerIndex);
+            char *currentName = m_deletableChildren->ElementAt(innerIndex);
             if (!longestName || strlen(longestName) < strlen(currentName))
             {
                 longestName = currentName;
                 longestIndex = innerIndex;
             }
         }
         // the imap parser has already converted to a non UTF7 string in
         // the canonical format so convert it back
@@ -6921,17 +6920,17 @@ bool nsImapProtocol::DeleteSubFolders(co
           else
           {
               nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryReferent(m_server);
               if (imapServer)
                   imapServer->ResetConnection(nsDependentCString(longestName));
               bool deleted = false;
               if( folderInSubfolderList )	// for performance
               {
-                  nsVoidArray* pDeletableChildren = m_deletableChildren;
+                  nsTArray<char*> *pDeletableChildren = m_deletableChildren;
                   m_deletableChildren = nullptr;
                   bool folderDeleted = true;
                   deleted = DeleteSubFolders(longestName, folderDeleted);
                   // longestName may have subfolder list including itself
                   if( !folderDeleted )
                   {
                       if (deleted)
                       deleted = DeleteMailboxRespectingSubscriptions(longestName);
@@ -7375,29 +7374,29 @@ void nsImapProtocol::DiscoverMailboxList
 
   m_hierarchyNameState = kNoOperationInProgress;
 
   MailboxDiscoveryFinished();
 
   // Get the ACLs for newly discovered folders
   if (GetServerStateParser().ServerHasACLCapability())
   {
-    int32_t total = m_listedMailboxList.Count(), cnt = 0;
+    int32_t total = m_listedMailboxList.Length(), cnt = 0;
     // Let's not turn this off here, since we don't turn it on after
     // GetServerStateParser().SetReportingErrors(false);
     if (total)
     {
       ProgressEventFunctionUsingName("imapGettingACLForFolder");
       nsIMAPMailboxInfo * mb = nullptr;
       do
       {
-        if (m_listedMailboxList.Count() == 0)
+        if (m_listedMailboxList.Length() == 0)
             break;
 
-        mb = (nsIMAPMailboxInfo *) m_listedMailboxList[0]; // get top element
+        mb = m_listedMailboxList[0]; // get top element
         m_listedMailboxList.RemoveElementAt(0); // XP_ListRemoveTopObject(fListedMailboxList);
         if (mb)
         {
           if (FolderNeedsACLInitialized(PromiseFlatCString(mb->GetMailboxName()).get()))
           {
             char *onlineName = nullptr;
             m_runningUrl->AllocateServerPath(PromiseFlatCString(mb->GetMailboxName()).get(),
                                              mb->GetDelimiter(), &onlineName);
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -28,17 +28,16 @@
 #include "nsIImapMessageSink.h"
 
 // UI Thread proxy helper
 #include "nsIImapProtocolSink.h"
 
 #include "nsImapServerResponseParser.h"
 #include "nsImapFlagAndUidState.h"
 #include "nsIMAPNamespace.h"
-#include "nsVoidArray.h"
 #include "nsTArray.h"
 #include "nsWeakPtr.h"
 #include "nsMsgLineBuffer.h" // we need this to use the nsMsgLineStreamBuffer helper class...
 #include "nsIInputStream.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsCOMArray.h"
 #include "nsIThread.h"
 #include "nsIRunnable.h"
@@ -56,16 +55,17 @@
 #include "nsIMsgFolder.h"
 #include "nsIMsgAsyncPrompter.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "nsSyncRunnableHelpers.h"
 
 class nsIMAPMessagePartIDArray;
 class nsIMsgIncomingServer;
 class nsIPrefBranch;
+class nsIMAPMailboxInfo;
 
 #define kDownLoadCacheSize 16000 // was 1536 - try making it bigger
 
 
 typedef struct _msg_line_info {
     const char   *adoptedMessageLine;
     uint32_t uidOfMessage;
 } msg_line_info;
@@ -658,18 +658,18 @@ private:
       kListingForInfoAndDiscovery,
       kDiscoveringNamespacesOnly,
       kXListing,
       kListingForFolderFlags,
       kListingForCreate
   };
   EMailboxHierarchyNameState  m_hierarchyNameState;
   EMailboxDiscoverStatus      m_discoveryStatus;
-  nsVoidArray                 m_listedMailboxList;
-  nsVoidArray*                m_deletableChildren;
+  nsTArray<nsIMAPMailboxInfo*> m_listedMailboxList;
+  nsTArray<char*> *            m_deletableChildren;
   uint32_t                    m_flagChangeCount;
   PRTime                      m_lastCheckTime;
 
   bool CheckNeeded();
 
   nsString m_emptyMimePartString;
 
   nsRefPtr<mozilla::mailnews::OAuth2ThreadHelper> mOAuth2Support;
--- a/mailnews/imap/src/nsImapSearchResults.cpp
+++ b/mailnews/imap/src/nsImapSearchResults.cpp
@@ -16,26 +16,23 @@ nsImapSearchResultSequence::nsImapSearch
 
 nsImapSearchResultSequence *nsImapSearchResultSequence::CreateSearchResultSequence()
 {
   return new nsImapSearchResultSequence;
 }
 
 void nsImapSearchResultSequence::Clear(void)
 {
-  if (mImpl) 
-  {
-    int32_t i = mImpl->mCount;
+    int32_t i = Length();
     while (0 <= --i) 
     {
-      char* string = (char*)mImpl->mArray[i];
+      char* string = ElementAt(i);
       PR_Free(string);
     }
-    nsVoidArray::Clear();
-  }
+    nsTArray<char*>::Clear();
 }
 
 nsImapSearchResultSequence::~nsImapSearchResultSequence()
 {
   Clear();
 }
 
 
--- a/mailnews/imap/src/nsImapSearchResults.h
+++ b/mailnews/imap/src/nsImapSearchResults.h
@@ -1,19 +1,19 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsImapSearchResults_h___
 #define nsImapSearchResults_h___
 
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
-class nsImapSearchResultSequence : public nsVoidArray
+class nsImapSearchResultSequence : public nsTArray<char*>
 {
 public:
     virtual ~nsImapSearchResultSequence();
     static nsImapSearchResultSequence *CreateSearchResultSequence();
     
     virtual void AddSearchResultLine(const char *searchLine);
     virtual void ResetSequence();
     void  Clear();
--- a/mailnews/import/eudora/src/nsEudoraAddress.cpp
+++ b/mailnews/import/eudora/src/nsEudoraAddress.cpp
@@ -32,17 +32,17 @@
   }
 
 
 // If we get a line longer than 16K it's just toooooo bad!
 #define kEudoraAddressBufferSz  (16 * 1024)
 
 
 #ifdef IMPORT_DEBUG
-void DumpAliasArray(nsVoidArray& a);
+void DumpAliasArray(nsTArray<CAliasEntry*>& a);
 #endif
 
 class CAliasData {
 public:
   CAliasData() {}
   ~CAliasData() {}
 
   bool Process(const char *pLine, int32_t len);
@@ -56,26 +56,26 @@ public:
 
 class CAliasEntry {
 public:
   CAliasEntry(nsCString& name) { m_name = name;}
   ~CAliasEntry() { EmptyList();}
 
   void EmptyList(void) {
     CAliasData *pData;
-    for (int32_t i = 0; i < m_list.Count(); i++) {
+    for (int32_t i = 0; i < m_list.Length(); i++) {
       pData = (CAliasData *)m_list.ElementAt(i);
       delete pData;
     }
     m_list.Clear();
   }
 
 public:
   nsCString  m_name;
-  nsVoidArray  m_list;
+  nsTArray<CAliasData*>  m_list;
   nsCString  m_notes;
 };
 
 nsEudoraAddress::nsEudoraAddress()
 {
 }
 
 nsEudoraAddress::~nsEudoraAddress()
@@ -152,18 +152,18 @@ int32_t nsEudoraAddress::CountWhiteSpace
   }
 
   return cnt;
 }
 
 void nsEudoraAddress::EmptyAliases(void)
 {
   CAliasEntry *pData;
-  for (int32_t i = 0; i < m_alias.Count(); i++) {
-    pData = (CAliasEntry *)m_alias.ElementAt(i);
+  for (int32_t i = 0; i < m_alias.Length(); i++) {
+    pData = m_alias.ElementAt(i);
     delete pData;
   }
   m_alias.Clear();
 }
 
 void nsEudoraAddress::ProcessLine(const char *pLine, int32_t len, nsString& errors)
 {
   if (len < 6)
@@ -326,17 +326,17 @@ void nsEudoraAddress::ProcessNote(const 
     return;
 
   // Find the alias for this note and store the note data there!
   CAliasEntry *pEntry = nullptr;
   int32_t  idx = FindAlias(name);
   if (idx == -1)
     return;
 
-  pEntry = (CAliasEntry *) m_alias.ElementAt(idx);
+  pEntry = m_alias.ElementAt(idx);
   pEntry->m_notes.Append(pLine, len);
   pEntry->m_notes.Trim(kWhitespace);
 }
 
 
 
 int32_t nsEudoraAddress::CountQuote(const char *pLine, int32_t len)
 {
@@ -528,68 +528,68 @@ bool CAliasData::Process(const char *pLi
   m_realName = StringHead(str, tCnt);
   m_realName.Trim(kWhitespace);
   m_email.Trim(kWhitespace);
 
   return !m_email.IsEmpty();
 }
 
 #ifdef IMPORT_DEBUG
-void DumpAliasArray(nsVoidArray& a)
+void DumpAliasArray(nsTArray<CAliasEntry*>& a)
 {
   CAliasEntry *pEntry;
   CAliasData *pData;
 
-  int32_t cnt = a.Count();
+  int32_t cnt = a.Length();
   IMPORT_LOG1("Alias list size: %ld\n", cnt);
   for (int32_t i = 0; i < cnt; i++) {
-    pEntry = (CAliasEntry *)a.ElementAt(i);
+    pEntry = a.ElementAt(i);
     IMPORT_LOG1("\tAlias: %s\n", pEntry->m_name.get());
-    if (pEntry->m_list.Count() > 1) {
-      IMPORT_LOG1("\tList count #%ld\n", pEntry->m_list.Count());
-      for (int32_t j = 0; j < pEntry->m_list.Count(); j++) {
+    if (pEntry->m_list.Length() > 1) {
+      IMPORT_LOG1("\tList count #%ld\n", pEntry->m_list.Length());
+      for (int32_t j = 0; j < pEntry->m_list.Length(); j++) {
         pData = (CAliasData *) pEntry->m_list.ElementAt(j);
         IMPORT_LOG0("\t\t--------\n");
         IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
         IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
         IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
       }
     }
-    else if (pEntry->m_list.Count()) {
+    else if (pEntry->m_list.Length()) {
       pData = (CAliasData *) pEntry->m_list.ElementAt(0);
       IMPORT_LOG1("\t\temail: %s\n", pData->m_email.get());
       IMPORT_LOG1("\t\trealName: %s\n", pData->m_realName.get());
       IMPORT_LOG1("\t\tnickName: %s\n", pData->m_nickName.get());
     }
   }
 }
 #endif
 
 CAliasEntry *nsEudoraAddress::ResolveAlias(nsCString& name)
 {
-  int32_t  max = m_alias.Count();
+  int32_t  max = m_alias.Length();
   CAliasEntry *pEntry;
   for (int32_t i = 0; i < max; i++) {
-    pEntry = (CAliasEntry *) m_alias.ElementAt(i);
+    pEntry = m_alias.ElementAt(i);
     if (name.Equals(pEntry->m_name, nsCaseInsensitiveCStringComparator()))
       return pEntry;
   }
 
   return nullptr;
 }
 
-void nsEudoraAddress::ResolveEntries(nsCString& name, nsVoidArray& list,
-                                     nsVoidArray& result, bool addResolvedEntries,
+void nsEudoraAddress::ResolveEntries(nsCString& name, nsTArray<CAliasData*>& list,
+                                     nsTArray<CAliasData*>& result, bool addResolvedEntries,
                                      bool wasResolved, int32_t& numResolved)
 {
     /* a safe-guard against recursive entries */
-    if (result.Count() > m_alias.Count())
+    if (result.Length() > m_alias.Length())
         return;
 
-    int32_t         max = list.Count();
+    int32_t         max = list.Length();
     int32_t         i;
     CAliasData *    pData;
     CAliasEntry *   pEntry;
     for (i = 0; i < max; i++) {
         pData = (CAliasData *)list.ElementAt(i);
         // resolve the email to an existing alias!
         if (!name.Equals(pData->m_email, nsCaseInsensitiveCStringComparator()) &&
              ((pEntry = ResolveAlias(pData->m_fullEntry)) != nullptr)) {
@@ -612,54 +612,54 @@ void nsEudoraAddress::ResolveEntries(nsC
             result.AppendElement(pData);
         }
     }
 }
 
 int32_t nsEudoraAddress::FindAlias(nsCString& name)
 {
   CAliasEntry *  pEntry;
-  int32_t      max = m_alias.Count();
+  int32_t      max = m_alias.Length();
   int32_t      i;
 
   for (i = 0; i < max; i++) {
-    pEntry = (CAliasEntry *) m_alias.ElementAt(i);
+    pEntry = m_alias.ElementAt(i);
     if (pEntry->m_name == name)
       return i;
   }
 
   return -1;
 }
 
 void nsEudoraAddress::BuildABCards(uint32_t *pBytes, nsIAddrDatabase *pDb)
 {
   CAliasEntry *  pEntry;
-  int32_t      max = m_alias.Count();
+  int32_t      max = m_alias.Length();
   int32_t      i;
-  nsVoidArray    emailList;
-  nsVoidArray membersArray;// Remember group members.
-  nsVoidArray groupsArray; // Remember groups.
+  nsTArray<CAliasData*>    emailList;
+  nsTArray<CAliasData*> membersArray; // Remember group members.
+  nsTArray<CAliasEntry*> groupsArray; // Remember groups.
 
   // First off, run through the list and build person cards - groups/lists have to be done later
   for (i = 0; i < max; i++) {
     int32_t   numResolved = 0;
-    pEntry = (CAliasEntry *) m_alias.ElementAt(i);
+    pEntry = m_alias.ElementAt(i);
 
     // false for 4th parameter tells ResolveEntries not to add resolved entries (avoids
     // duplicates as mailing lists are being resolved to other cards - the other cards that
     // are found have already been added and don't need to be added again).
     //
     // false for 5th parameter tells ResolveEntries that we're calling it - it's not being
     // called recursively by itself.
     ResolveEntries(pEntry->m_name, pEntry->m_list, emailList, false, false, numResolved);
 
     // Treat it as a group if there's more than one email address or if we
     // needed to resolve one or more aliases. We treat single aliases to
     // other aliases as a mailing list because there's no better equivalent.
-    if ((emailList.Count() > 1) || (numResolved > 0))
+    if ((emailList.Length() > 1) || (numResolved > 0))
     {
       // Remember group members uniquely and add them to db later.
       RememberGroupMembers(membersArray, emailList);
       // Remember groups and add them to db later.
       groupsArray.AppendElement(pEntry);
     }
     else
       AddSingleCard(pEntry, emailList, pDb);
@@ -673,21 +673,21 @@ void nsEudoraAddress::BuildABCards(uint3
   }
 
   // Make sure group members exists before adding groups.
   nsresult rv = AddGroupMembersAsCards(membersArray, pDb);
   if (NS_FAILED(rv))
     return;
 
   // Now add the lists/groups (now that all cards have been added).
-  max = groupsArray.Count();
+  max = groupsArray.Length();
   for (i = 0; i < max; i++)
   {
     int32_t   numResolved = 0;
-    pEntry = (CAliasEntry *) groupsArray.ElementAt(i);
+    pEntry = groupsArray.ElementAt(i);
 
     // false for 4th parameter tells ResolveEntries to add resolved entries so that we
     // can create the mailing list with references to all entries correctly.
     //
     // false for 5th parameter tells ResolveEntries that we're calling it - it's not being
     // called recursively by itself.
     ResolveEntries(pEntry->m_name, pEntry->m_list, emailList, true, false, numResolved);
     AddSingleList(pEntry, emailList, pDb);
@@ -751,17 +751,17 @@ void nsEudoraAddress::SplitString(nsCStr
     idx= val1.RFindChar(10);
   if (idx != -1) {
     val2 = Substring(val1, idx + cnt);
     val1.SetLength(idx);
     SanitizeValue(val1);
   }
 }
 
-void nsEudoraAddress::AddSingleCard(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
+void nsEudoraAddress::AddSingleCard(CAliasEntry *pEntry, nsTArray<CAliasData*> &emailList, nsIAddrDatabase *pDb)
 {
   // We always have a nickname and everything else is optional.
   // Map both home and work related fields to our address card. Eudora
   // fields that can't be mapped will be left in the 'note' field!
   nsIMdbRow* newRow = nullptr;
   pDb->GetNewRow(&newRow);
   if (!newRow)
     return;
@@ -858,17 +858,17 @@ void nsEudoraAddress::AddSingleCard(CAli
         // Store other web sites in the notes field, labeled nicely
         FormatExtraDataInNoteField(EUDORAIMPORT_ADDRESS_LABEL_OTHERWEB, otherWeb, noteUTF16);
       }
 
       noteUTF16.Append(NS_ConvertASCIItoUTF16(note));
     }
   }
 
-  CAliasData *pData = emailList.Count() ? (CAliasData *)emailList.ElementAt(0) : nullptr;
+  CAliasData *pData = emailList.Length() ? (CAliasData *)emailList.ElementAt(0) : nullptr;
 
   if (pData && !pData->m_realName.IsEmpty())
     displayName = pData->m_realName;
   else if (!name.IsEmpty())
     displayName = name;
   else
     displayName = pEntry->m_name;
 
@@ -1002,42 +1002,42 @@ void nsEudoraAddress::AddSingleCard(CAli
   }
 }
 
 //
 // Since there is no way to check if a card for a given email address already exists,
 // elements in 'membersArray' are make unique. So for each email address in 'emailList'
 // we check it in 'membersArray' and if it's not there then we add it to 'membersArray'.
 //
-void nsEudoraAddress::RememberGroupMembers(nsVoidArray &membersArray, nsVoidArray &emailList)
+void nsEudoraAddress::RememberGroupMembers(nsTArray<CAliasData*> &membersArray, nsTArray<CAliasData*> &emailList)
 {
-  int32_t cnt = emailList.Count();
+  int32_t cnt = emailList.Length();
   CAliasData *pData;
 
   for (int32_t i = 0; i < cnt; i++)
   {
     pData = (CAliasData *)emailList.ElementAt(i);
     if (!pData)
       continue;
 
-    int32_t memberCnt = membersArray.Count();
+    int32_t memberCnt = membersArray.Length();
     int32_t j = 0;
     for (j = 0; j < memberCnt; j++)
     {
       if (pData == membersArray.ElementAt(j))
         break;
     }
     if (j >= memberCnt)
       membersArray.AppendElement(pData); // add to member list
   }
 }
 
-nsresult nsEudoraAddress::AddGroupMembersAsCards(nsVoidArray &membersArray, nsIAddrDatabase *pDb)
+nsresult nsEudoraAddress::AddGroupMembersAsCards(nsTArray<CAliasData*> &membersArray, nsIAddrDatabase *pDb)
 {
-  int32_t max = membersArray.Count();
+  int32_t max = membersArray.Length();
   CAliasData *pData;
   nsresult rv = NS_OK;
   nsCOMPtr <nsIMdbRow> newRow;
   nsAutoString uniStr;
   nsAutoCString  displayName;
 
   for (int32_t i = 0; i < max; i++)
   {
@@ -1060,17 +1060,17 @@ nsresult nsEudoraAddress::AddGroupMember
     ADD_FIELD_TO_DB_ROW(pDb, AddDisplayName, newRow, displayName, uniStr);
     ADD_FIELD_TO_DB_ROW(pDb, AddPrimaryEmail, newRow, pData->m_email, uniStr);
     rv = pDb->AddCardRowToDB(newRow);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return rv;
 }
 
-nsresult nsEudoraAddress::AddSingleList(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb)
+nsresult nsEudoraAddress::AddSingleList(CAliasEntry *pEntry, nsTArray<CAliasData*> &emailList, nsIAddrDatabase *pDb)
 {
   // Create a list.
   nsCOMPtr <nsIMdbRow> newRow;
   nsresult rv = pDb->GetNewListRow(getter_AddRefs(newRow));
   if (NS_FAILED(rv) || !newRow)
       return rv;
 
   // Extract name from notes, if any
@@ -1087,17 +1087,17 @@ nsresult nsEudoraAddress::AddSingleList(
   rv = pDb->AddListName(newRow, name.IsEmpty() ? pEntry->m_name.get() : name.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Add the name in pEntry as the list nickname, because it was the Eudora nickname
   rv = pDb->AddListNickName(newRow, pEntry->m_name.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now add the members.
-  int32_t max = emailList.Count();
+  int32_t max = emailList.Length();
   for (int32_t i = 0; i < max; i++)
   {
     CAliasData *pData = (CAliasData *)emailList.ElementAt(i);
     nsAutoCString ldifValue("mail");
     ldifValue.Append(pData->m_email);
     rv = pDb->AddLdifListMember(newRow, ldifValue.get());
   }
 
--- a/mailnews/import/eudora/src/nsEudoraAddress.h
+++ b/mailnews/import/eudora/src/nsEudoraAddress.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsEudoraAddress_h__
 #define nsEudoraAddress_h__
 
 #include "nscore.h"
 #include "nsStringGlue.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsIFile.h"
 #include "nsCOMPtr.h"
 #include "nsIImportService.h"
 
 
 class nsIAddrDatabase;
 class CAliasEntry;
 class CAliasData;
@@ -44,33 +44,33 @@ public:
 private:
   void       EmptyAliases(void);
   void      ProcessLine(const char *pLine, int32_t len, nsString& errors);
   int32_t     CountWhiteSpace(const char *pLine, int32_t len);
   CAliasEntry  *  ProcessAlias(const char *pLine, int32_t len, nsString& errors);
   void      ProcessNote(const char *pLine, int32_t len, nsString& errors);
   int32_t      GetAliasName(const char *pLine, int32_t len, nsCString& name);
   CAliasEntry *  ResolveAlias(nsCString& name);
-  void       ResolveEntries(nsCString& name, nsVoidArray& list, nsVoidArray& result, bool addResolvedEntries, bool wasResolved, int32_t& numResolved);
+  void       ResolveEntries(nsCString& name, nsTArray<CAliasData*>& list, nsTArray<CAliasData*>& result, bool addResolvedEntries, bool wasResolved, int32_t& numResolved);
   void      BuildABCards(uint32_t *pBytes, nsIAddrDatabase *pDb);
-  void      AddSingleCard(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
-  nsresult  AddSingleList(CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
-  nsresult  AddGroupMembersAsCards(nsVoidArray &membersArray, nsIAddrDatabase *pDb);
-  void      RememberGroupMembers(nsVoidArray &membersArray, nsVoidArray &emailList);
+  void      AddSingleCard(CAliasEntry *pEntry, nsTArray<CAliasData*> &emailList, nsIAddrDatabase *pDb);
+  nsresult  AddSingleList(CAliasEntry *pEntry, nsTArray<CAliasData*> &emailList, nsIAddrDatabase *pDb);
+  nsresult  AddGroupMembersAsCards(nsTArray<CAliasData*> &membersArray, nsIAddrDatabase *pDb);
+  void      RememberGroupMembers(nsTArray<CAliasData*> &membersArray, nsTArray<CAliasData*> &emailList);
   int32_t      FindAlias(nsCString& name);
   void      ExtractNoteField(nsCString& note, nsCString& field, const char *pFieldName);
   void FormatExtraDataInNoteField(int32_t labelStringID, nsCString& extraData, nsString& noteUTF16);
   void      SanitizeValue(nsCString& val);
   void      SplitString(nsCString& val1, nsCString& val2);
 
 public:
   static int32_t     CountQuote(const char *pLine, int32_t len);
   static int32_t     CountComment(const char *pLine, int32_t len);
   static int32_t     CountAngle(const char *pLine, int32_t len);
 
 private:
-  nsVoidArray    m_alias;
+  nsTArray<CAliasEntry*>  m_alias;
 };
 
 
 
 #endif /* nsEudoraAddress_h__ */
 
--- a/mailnews/import/eudora/src/nsEudoraCompose.cpp
+++ b/mailnews/import/eudora/src/nsEudoraCompose.cpp
@@ -503,17 +503,17 @@ nsresult nsEudoraCompose::GetLocalAttach
   nsIURI      *url = nullptr;
   */
   nsresult rv;
   nsCOMPtr<nsIMutableArray> attachments (do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_IF_ADDREF(*aArray = attachments);
   int32_t count = 0;
   if (m_pAttachments)
-    count = m_pAttachments->Count();
+    count = m_pAttachments->Length();
   if (!count)
     return NS_OK;
 
   nsCString urlStr;
   ImportAttachment * pAttach;
 
   for (int32_t i = 0; i < count; i++) {
     nsCOMPtr<nsIMsgAttachedFile> a(do_CreateInstance(NS_MSGATTACHEDFILE_CONTRACTID, &rv));
--- a/mailnews/import/eudora/src/nsEudoraCompose.h
+++ b/mailnews/import/eudora/src/nsEudoraCompose.h
@@ -8,17 +8,17 @@
 #define nsEudoraCompose_h__
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsStringGlue.h"
 #include "nsMsgUtils.h"
 #include "nsIFile.h"
 #include "nsIInputStream.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsIImportService.h"
 
 #ifdef MOZILLA_INTERNAL_API
 #include "nsNativeCharsetUtils.h"
 #else
 #include "nsMsgI18N.h"
 #define NS_CopyNativeToUnicode(source, dest) \
         nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(), source, dest)
@@ -112,17 +112,17 @@ class nsEudoraCompose {
 public:
   nsEudoraCompose();
   ~nsEudoraCompose();
 
   nsresult  SendTheMessage(nsIFile *pMailImportLocation, nsIFile **pMsg);
 
   void    SetBody(const char *pBody, int32_t len, nsCString &bodyType) { m_pBody = pBody; m_bodyLen = len; m_bodyType = bodyType;}
   void    SetHeaders(const char *pHeaders, int32_t len) { m_pHeaders = pHeaders; m_headerLen = len;}
-  void    SetAttachments(nsVoidArray *pAttachments) { m_pAttachments = pAttachments;}
+  void    SetAttachments(nsTArray<ImportAttachment*> *pAttachments) { m_pAttachments = pAttachments;}
   void    SetDefaultDate(nsCString date) { m_defaultDate = date;}
 
   nsresult  CopyComposedMessage(nsCString& fromLine, nsIFile *pSrc, nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& copy);
 
   static nsresult  FillMailBuffer(ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
   static nsresult CreateIdentity(void);
   static void    ReleaseIdentity(void);
 
@@ -147,17 +147,17 @@ private:
   int32_t    IsEndHeaders(SimpleBufferTonyRCopiedOnce& data);
   int32_t    IsSpecialHeader(const char *pHeader);
   nsresult  WriteHeaders(nsIOutputStream *pDst, SimpleBufferTonyRCopiedOnce& newHeaders);
   bool      IsReplaceHeader(const char *pHeader);
 
 private:
   static nsIMsgIdentity *    s_pIdentity;
 
-  nsVoidArray *      m_pAttachments;
+  nsTArray<ImportAttachment*> *  m_pAttachments;
   nsIMsgSendListener *  m_pListener;
   nsIMsgCompFields *    m_pMsgFields;
   nsCOMPtr<nsIIOService> m_pIOService;
   int32_t          m_headerLen;
   const char *      m_pHeaders;
   int32_t          m_bodyLen;
   const char *      m_pBody;
   nsCString        m_bodyType;
--- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ -1211,17 +1211,17 @@ nsresult nsEudoraMailbox::WriteFromSep(n
   nsresult rv = pDst->Write(eudoraFromLine, m_fromLen, &written);
   if (NS_SUCCEEDED(rv) && (written != m_fromLen))
     return NS_ERROR_FAILURE;
   return rv;
 }
 
 void nsEudoraMailbox::EmptyAttachments(void)
 {
-  int32_t max = m_attachments.Count();
+  int32_t max = m_attachments.Length();
   ImportAttachment *  pAttach;
   for (int32_t i = 0; i < max; i++) {
     pAttach = (ImportAttachment *) m_attachments.ElementAt(i);
     if (pAttach) {
       NS_Free(pAttach->description);
       NS_Free(pAttach->mimeType);
       delete pAttach;
     }
--- a/mailnews/import/eudora/src/nsEudoraMailbox.h
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsEudoraMailbox_h__
 #define nsEudoraMailbox_h__
 
 #include "nscore.h"
 #include "nsStringGlue.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsIFile.h"
 #include "nsEudoraCompose.h"
 
 class nsIOutputStream;
 class nsIMutableArray;
 
 /////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////
@@ -187,15 +187,15 @@ private:
   static int      IsMonthStr(const char *pStr);
 
 protected:
   nsCOMPtr <nsIFile>    m_mailImportLocation;
 
 private:
   int64_t    m_mailSize;
   uint32_t      m_fromLen;
-  nsVoidArray    m_attachments;
+  nsTArray<ImportAttachment*>  m_attachments;
 };
 
 
 
 #endif /* nsEudoraMailbox_h__ */
 
--- a/mailnews/import/oexpress/nsOEScanBoxes.cpp
+++ b/mailnews/import/oexpress/nsOEScanBoxes.cpp
@@ -42,24 +42,24 @@ nsOEScanBoxes::nsOEScanBoxes()
 {
   m_pFirst = nullptr;
 }
 
 nsOEScanBoxes::~nsOEScanBoxes()
 {
   int i, max;
   MailboxEntry *pEntry;
-  for (i = 0, max = m_entryArray.Count(); i < max; i++) {
-    pEntry = (MailboxEntry *) m_entryArray.ElementAt(i);
+  for (i = 0, max = m_entryArray.Length(); i < max; i++) {
+    pEntry = m_entryArray.ElementAt(i);
     delete pEntry;
   }
   // Now free the unprocessed child entries (ie, those without parents for some reason).
-  for (i = 0, max = m_pendingChildArray.Count(); i < max; i++)
+  for (i = 0, max = m_pendingChildArray.Length(); i < max; i++)
   {
-    pEntry = (MailboxEntry *) m_pendingChildArray.ElementAt(i);
+    pEntry = m_pendingChildArray.ElementAt(i);
     if (!pEntry->processed)
       delete pEntry;
   }
 }
 
 /*
  3.x & 4.x registry
   Software/Microsoft/Outlook Express/
@@ -179,19 +179,19 @@ bool nsOEScanBoxes::GetMailboxes(nsIFile
 
   return result;
 }
 
 
 
 void nsOEScanBoxes::Reset(void)
 {
-  int max = m_entryArray.Count();
+  int max = m_entryArray.Length();
   for (int i = 0; i < max; i++) {
-    MailboxEntry *pEntry = (MailboxEntry *) m_entryArray.ElementAt(i);
+    MailboxEntry *pEntry = m_entryArray.ElementAt(i);
     delete pEntry;
   }
   m_entryArray.Clear();
   m_pFirst = nullptr;
 }
 
 
 bool nsOEScanBoxes::FindMailBoxes(nsIFile* descFile)
@@ -265,17 +265,17 @@ bool nsOEScanBoxes::FindMailBoxes(nsIFil
     if (!next)
       done = true;
   }
 
   MailboxEntry *pZero = GetIndexEntry(0);
   if (pZero)
     m_pFirst = GetIndexEntry(pZero->child);
 
-  IMPORT_LOG1("Read the folders.nch file, found %ld mailboxes\n", (long) m_entryArray.Count());
+  IMPORT_LOG1("Read the folders.nch file, found %ld mailboxes\n", (long) m_entryArray.Length());
 
   return true;
 }
 
 bool nsOEScanBoxes::Find50MailBoxes(nsIFile* descFile)
 {
   Reset();
 
@@ -422,17 +422,17 @@ bool nsOEScanBoxes::Find50MailBoxes(nsIF
     }
 
     delete [] pBytes;
   }
 
 
   delete [] pIndex;
 
-  return m_entryArray.Count();
+  return m_entryArray.Length();
 }
 
 nsOEScanBoxes::MailboxEntry *nsOEScanBoxes::NewMailboxEntry(uint32_t id, uint32_t parent, const char *prettyName, char *pFileName)
 {
   MailboxEntry *pEntry = new MailboxEntry();
   if (!pEntry)
     return nullptr;
 
@@ -443,23 +443,23 @@ nsOEScanBoxes::MailboxEntry *nsOEScanBox
   pEntry->sibling = -1;
   pEntry->processed =  false;
   NS_CopyNativeToUnicode(nsDependentCString(prettyName), pEntry->mailName);
   if (pFileName)
     pEntry->fileName = pFileName;
   return pEntry;
 }
 
-void nsOEScanBoxes::ProcessPendingChildEntries(uint32_t parent, uint32_t rootIndex, nsVoidArray  &childArray)
+void nsOEScanBoxes::ProcessPendingChildEntries(uint32_t parent, uint32_t rootIndex, nsTArray<MailboxEntry*>  &childArray)
 {
   int32_t i, max;
   MailboxEntry *pEntry;
-  for (i = 0, max = childArray.Count(); i < max; i++)
+  for (i = 0, max = childArray.Length(); i < max; i++)
   {
-    pEntry = (MailboxEntry *) childArray.ElementAt(i);
+    pEntry = childArray.ElementAt(i);
     if ((!pEntry->processed) && (pEntry->parent == parent))
     {
       AddChildEntry(pEntry, rootIndex);
       pEntry->processed =  true; // indicate it's been processed.
       // See if there are unprocessed child folders for this child in the
       // array as well (ie, both child and grand-child are on the list).
       ProcessPendingChildEntries(pEntry->index, rootIndex, childArray);
     }
@@ -467,19 +467,19 @@ void nsOEScanBoxes::ProcessPendingChildE
 }
 
 void nsOEScanBoxes::RemoveProcessedChildEntries()
 {
   // Remove already processed entries from the pending list. Note that these entries are also
   // on 'm_entryArray' list so we don't want to deallocate the space for the entries now.
   MailboxEntry * pEntry;
   int32_t i;
-  for (i = m_pendingChildArray.Count()-1; i >= 0; i--)
+  for (i = m_pendingChildArray.Length()-1; i >= 0; i--)
   {
-    pEntry = (MailboxEntry *) m_pendingChildArray.ElementAt(i);
+    pEntry = m_pendingChildArray.ElementAt(i);
     if (pEntry->processed)
       m_pendingChildArray.RemoveElementAt(i);
   }
 }
 
 void nsOEScanBoxes::AddChildEntry(MailboxEntry *pEntry, uint32_t rootIndex)
 {
   if (!m_pFirst) {
@@ -574,18 +574,18 @@ bool nsOEScanBoxes::Scan50MailboxDir(nsI
             pEntry->fileName = fName.get();
             NS_CopyNativeToUnicode(fName, pEntry->mailName);
             m_entryArray.AppendElement(pEntry);
           }
       }
     }
   }
 
-  if (m_entryArray.Count() > 0) {
-    pEntry = (MailboxEntry *)m_entryArray.ElementAt(m_entryArray.Count() - 1);
+  if (m_entryArray.Length() > 0) {
+    pEntry = m_entryArray.ElementAt(m_entryArray.Length() - 1);
     pEntry->sibling = -1;
     return true;
   }
 
   return false;
 }
 
 void nsOEScanBoxes::ScanMailboxDir(nsIFile * srcDir)
@@ -639,30 +639,30 @@ void nsOEScanBoxes::ScanMailboxDir(nsIFi
           pEntry->fileName = pLeaf;
           pLeaf.SetLength(sLen - 4);
           NS_CopyNativeToUnicode(pLeaf, pEntry->mailName);
           m_entryArray.AppendElement(pEntry);
       }
     }
   }
 
-  if (m_entryArray.Count() > 0) {
-    pEntry = (MailboxEntry *)m_entryArray.ElementAt(m_entryArray.Count() - 1);
+  if (m_entryArray.Length() > 0) {
+    pEntry = m_entryArray.ElementAt(m_entryArray.Length() - 1);
     pEntry->sibling = -1;
   }
 }
 
 uint32_t nsOEScanBoxes::CountMailboxes(MailboxEntry *pBox)
 {
   if (pBox == nullptr) {
     if (m_pFirst != nullptr)
       pBox = m_pFirst;
     else {
-      if (m_entryArray.Count() > 0)
-        pBox = (MailboxEntry *) m_entryArray.ElementAt(0);
+      if (m_entryArray.Length() > 0)
+        pBox = m_entryArray.ElementAt(0);
     }
   }
   uint32_t    count = 0;
 
   MailboxEntry *  pChild;
   while (pBox) {
     count++;
     if (pBox->child) {
@@ -699,18 +699,18 @@ void nsOEScanBoxes::BuildMailboxList(Mai
 {
   if (pBox == nullptr) {
     if (m_pFirst != nullptr) {
       pBox = m_pFirst;
 
       IMPORT_LOG0("Assigning start of mailbox list to m_pFirst\n");
     }
     else {
-      if (m_entryArray.Count() > 0) {
-        pBox = (MailboxEntry *) m_entryArray.ElementAt(0);
+      if (m_entryArray.Length() > 0) {
+        pBox = m_entryArray.ElementAt(0);
 
         IMPORT_LOG0("Assigning start of mailbox list to entry at index 0\n");
       }
     }
 
     if (pBox == nullptr) {
       IMPORT_LOG0("ERROR ASSIGNING STARTING MAILBOX\n");
     }
@@ -758,19 +758,19 @@ void nsOEScanBoxes::BuildMailboxList(Mai
     else
       pBox = nullptr;
   }
 
 }
 
 nsOEScanBoxes::MailboxEntry * nsOEScanBoxes::GetIndexEntry(uint32_t index)
 {
-  int32_t max = m_entryArray.Count();
+  int32_t max = m_entryArray.Length();
   for (int32_t i = 0; i < max; i++) {
-    MailboxEntry *pEntry = (MailboxEntry *) m_entryArray.ElementAt(i);
+    MailboxEntry *pEntry = m_entryArray.ElementAt(i);
     if (pEntry->index == index)
       return pEntry;
   }
 
   return nullptr;
 }
 
 
--- a/mailnews/import/oexpress/nsOEScanBoxes.h
+++ b/mailnews/import/oexpress/nsOEScanBoxes.h
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsOEScanBoxes_h___
 #define nsOEScanBoxes_h___
 
 #include "nsStringGlue.h"
 #include "nsIImportModule.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsIArray.h"
 #include "nsIMutableArray.h"
 #include "nsIFile.h"
 #include "nsIImportService.h"
 
 class nsIInputStream;
 
@@ -47,30 +47,30 @@ private:
 
   // If find mailboxes fails you can use this routine to get the raw mailbox file names
   void  ScanMailboxDir(nsIFile * srcDir);
   bool    Scan50MailboxDir(nsIFile * srcDir);
 
   MailboxEntry *  GetIndexEntry(uint32_t index);
   void      AddChildEntry(MailboxEntry *pEntry, uint32_t rootIndex);
   MailboxEntry *  NewMailboxEntry(uint32_t id, uint32_t parent, const char *prettyName, char *pFileName);
-  void        ProcessPendingChildEntries(uint32_t parent, uint32_t rootIndex, nsVoidArray &childArray);
+  void        ProcessPendingChildEntries(uint32_t parent, uint32_t rootIndex, nsTArray<MailboxEntry*> &childArray);
   void        RemoveProcessedChildEntries();
 
 
   bool        ReadLong(nsIInputStream * stream, int32_t& val, uint32_t offset);
   bool        ReadLong(nsIInputStream * stream, uint32_t& val, uint32_t offset);
   bool        ReadString(nsIInputStream * stream, nsString& str, uint32_t offset);
   bool        ReadString(nsIInputStream * stream, nsCString& str, uint32_t offset);
   uint32_t     CountMailboxes(MailboxEntry *pBox);
 
   void       BuildMailboxList(MailboxEntry *pBox, nsIFile * root, int32_t depth, nsIMutableArray *pArray);
   bool         GetMailboxList(nsIFile * root, nsIArray **pArray);
 
 private:
   MailboxEntry *        m_pFirst;
-  nsVoidArray          m_entryArray;
-  nsVoidArray          m_pendingChildArray; // contains child folders whose parent folders have not showed up.
+  nsTArray<MailboxEntry*>  m_entryArray;
+  nsTArray<MailboxEntry*>  m_pendingChildArray; // contains child folders whose parent folders have not showed up.
 
   nsCOMPtr<nsIImportService>  mService;
 };
 
 #endif // nsOEScanBoxes_h__
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -11,17 +11,17 @@
 
 #include "prprf.h"
 #include "nsMemory.h"
 #include "nsMsgUtils.h"
 #include "nsUnicharUtils.h"
 
 int      CMapiApi::m_clients = 0;
 BOOL    CMapiApi::m_initialized = false;
-nsVoidArray  *CMapiApi::m_pStores = NULL;
+nsTArray<CMsgStore*>  *CMapiApi::m_pStores = NULL;
 LPMAPISESSION CMapiApi::m_lpSession = NULL;
 LPMDB    CMapiApi::m_lpMdb = NULL;
 HRESULT    CMapiApi::m_lastError;
 char16_t *  CMapiApi::m_pUniBuff = NULL;
 int      CMapiApi::m_uniBuffLen = 0;
 /*
 Type: 1, name: Calendar, class: IPF.Appointment
 Type: 1, name: Contacts, class: IPF.Contact
@@ -250,17 +250,17 @@ void CMapiApi::UnloadMapi(void)
   m_hMapi32 = NULL;
 }
 
 CMapiApi::CMapiApi()
 {
   m_clients++;
   LoadMapi();
   if (!m_pStores)
-    m_pStores = new nsVoidArray();
+    m_pStores = new nsTArray<CMsgStore*>();
 }
 
 CMapiApi::~CMapiApi()
 {
   m_clients--;
   if (!m_clients) {
     HRESULT  hr;
 
@@ -1101,18 +1101,18 @@ void CMapiApi::GetStoreInfo(CMapiFolder 
   }
 }
 
 
 void CMapiApi::ClearMessageStores(void)
 {
   if (m_pStores) {
     CMsgStore *  pStore;
-    for (int i = 0; i < m_pStores->Count(); i++) {
-      pStore = (CMsgStore *) m_pStores->ElementAt(i);
+    for (int i = 0; i < m_pStores->Length(); i++) {
+      pStore = m_pStores->ElementAt(i);
       delete pStore;
     }
     m_pStores->Clear();
   }
 }
 
 void CMapiApi::AddMessageStore(CMsgStore *pStore)
 {
@@ -1126,18 +1126,18 @@ CMsgStore *  CMapiApi::FindMessageStore(
     MAPI_TRACE0("FindMessageStore called before session is open\n");
     m_lastError = -1;
     return NULL;
   }
 
   ULONG    result;
   HRESULT    hr;
   CMsgStore *  pStore;
-  for (int i = 0; i < m_pStores->Count(); i++) {
-    pStore = (CMsgStore *) m_pStores->ElementAt(i);
+  for (int i = 0; i < m_pStores->Length(); i++) {
+    pStore = m_pStores->ElementAt(i);
     hr = m_lpSession->CompareEntryIDs(cbEid, lpEid, pStore->GetCBEntryID(), pStore->GetLPEntryID(),
                       0, &result);
     if (HR_FAILED(hr)) {
       MAPI_TRACE2("CompareEntryIDs failed: 0x%lx, %d\n", (long)hr, (int)hr);
       m_lastError = hr;
       return NULL;
     }
     if (result) {
@@ -1579,19 +1579,19 @@ void CMapiFolderList::EnsureUniqueName(C
   int        i;
   BOOL      done;
   nsString    name;
   nsString    cName;
 
   pFolder->GetDisplayName(name);
   do {
     done = TRUE;
-    i = m_array.Count() - 1;
+    i = m_array.Length() - 1;
     while (i >= 0) {
-      pCurrent = (CMapiFolder *)GetAt(i);
+      pCurrent = GetAt(i);
       if (pCurrent->GetDepth() == pFolder->GetDepth()) {
         pCurrent->GetDisplayName(cName);
         if (cName.Equals(name, nsCaseInsensitiveStringComparator())) {
           ChangeName(name);
           pFolder->SetDisplayName(name.get());
           done = FALSE;
           break;
         }
@@ -1610,19 +1610,19 @@ void CMapiFolderList::GenerateFilePath(C
   nsString    path;
   if (!pFolder->GetDepth()) {
     pFolder->GetDisplayName(name);
     pFolder->SetFilePath(name.get());
     return;
   }
 
   CMapiFolder *  pCurrent;
-  int        i = m_array.Count() - 1;
+  int        i = m_array.Length() - 1;
   while (i >= 0) {
-    pCurrent = (CMapiFolder *) GetAt(i);
+    pCurrent = GetAt(i);
     if (pCurrent->GetDepth() == (pFolder->GetDepth() - 1)) {
       pCurrent->GetFilePath(path);
       path.AppendLiteral(".sbd\\");
       pFolder->GetDisplayName(name);
       path += name;
       pFolder->SetFilePath(path.get());
       return;
     }
@@ -1630,33 +1630,33 @@ void CMapiFolderList::GenerateFilePath(C
   }
   pFolder->GetDisplayName(name);
   pFolder->SetFilePath(name.get());
 }
 
 void CMapiFolderList::ClearAll(void)
 {
   CMapiFolder *pFolder;
-  for (int i = 0; i < m_array.Count(); i++) {
-    pFolder = (CMapiFolder *)GetAt(i);
+  for (int i = 0; i < m_array.Length(); i++) {
+    pFolder = GetAt(i);
     delete pFolder;
   }
   m_array.Clear();
 }
 
 void CMapiFolderList::DumpList(void)
 {
   CMapiFolder *pFolder;
   nsString  str;
   int      depth;
   char    prefix[256];
 
   MAPI_TRACE0("Folder List ---------------------------------\n");
-  for (int i = 0; i < m_array.Count(); i++) {
-    pFolder = (CMapiFolder *)GetAt(i);
+  for (int i = 0; i < m_array.Length(); i++) {
+    pFolder = GetAt(i);
     depth = pFolder->GetDepth();
     pFolder->GetDisplayName(str);
     depth *= 2;
     if (depth > 255)
       depth = 255;
     memset(prefix, ' ', depth);
     prefix[depth] = 0;
 #ifdef MAPI_DEBUG
--- a/mailnews/import/outlook/src/MapiApi.h
+++ b/mailnews/import/outlook/src/MapiApi.h
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef MapiApi_h___
 #define MapiApi_h___
 
 #include "nscore.h"
 #include "nsStringGlue.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 #include <stdio.h>
 
 #include <windows.h>
 #include <mapi.h>
 #include <mapix.h>
 #include <mapidefs.h>
 #include <mapicode.h>
@@ -141,17 +141,17 @@ protected:
   static void      ReportStringProp(const char *pTag, LPSPropValue pVal);
   static void      ReportUIDProp(const char *pTag, LPSPropValue pVal);
   static void      ReportLongProp(const char *pTag, LPSPropValue pVal);
 
 
 private:
   static int        m_clients;
   static BOOL        m_initialized;
-  static nsVoidArray *  m_pStores;
+  static nsTArray<CMsgStore*> *  m_pStores;
   static LPMAPISESSION  m_lpSession;
   static LPMDB      m_lpMdb;
   static HRESULT      m_lastError;
   static char16_t *    m_pUniBuff;
   static int        m_uniBuffLen;
 
   static BOOL      GetLargeProperty(LPMAPIPROP pProp, ULONG tag, void** result);
 };
@@ -193,32 +193,32 @@ private:
 };
 
 class CMapiFolderList {
 public:
   CMapiFolderList();
   ~CMapiFolderList();
 
   void      AddItem(CMapiFolder *pFolder);
-  CMapiFolder *  GetItem(int index) { if ((index >= 0) && (index < m_array.Count())) return (CMapiFolder *)GetAt(index); else return NULL;}
+  CMapiFolder *  GetItem(int index) { if ((index >= 0) && (index < m_array.Length())) return GetAt(index); else return NULL;}
   void      ClearAll(void);
 
   // Debugging and reporting
   void      DumpList(void);
 
-  void *      GetAt(int index) { return m_array.ElementAt(index);}
-  int        GetSize(void) { return m_array.Count();}
+  CMapiFolder *  GetAt(int index) { return m_array.ElementAt(index);}
+  int        GetSize(void) { return m_array.Length();}
 
 protected:
   void  EnsureUniqueName(CMapiFolder *pFolder);
   void  GenerateFilePath(CMapiFolder *pFolder);
   void  ChangeName(nsString& name);
 
 private:
-  nsVoidArray    m_array;
+  nsTArray<CMapiFolder*>    m_array;
 };
 
 
 class CMsgStore {
 public:
   CMsgStore(ULONG cbEid = 0, LPENTRYID lpEid = NULL);
   ~CMsgStore();
 
--- a/mailnews/import/src/nsImportFieldMap.cpp
+++ b/mailnews/import/src/nsImportFieldMap.cpp
@@ -58,17 +58,17 @@ nsImportFieldMap::nsImportFieldMap(nsISt
   nsString *pStr;
   for (int32_t i = IMPORT_FIELD_DESC_START; i <= IMPORT_FIELD_DESC_END; i++, m_mozFieldCount++) {
     pStr = new nsString();
     if (pBundle) {
       nsImportStringBundle::GetStringByID(i, pBundle, *pStr);
     }
     else
       pStr->AppendInt(i);
-    m_descriptions.AppendElement((void *)pStr);
+    m_descriptions.AppendElement(pStr);
   }
 }
 
 nsImportFieldMap::~nsImportFieldMap()
 {
   if (m_pFields)
     delete [] m_pFields;
   if (m_pActive)
@@ -105,17 +105,17 @@ NS_IMETHODIMP nsImportFieldMap::GetMapSi
 
 NS_IMETHODIMP nsImportFieldMap::GetFieldDescription(int32_t index, char16_t **_retval)
 {
     NS_PRECONDITION(_retval != nullptr, "null ptr");
   if (!_retval)
     return NS_ERROR_NULL_POINTER;
 
   *_retval = nullptr;
-  if ((index < 0) || (index >= m_descriptions.Count()))
+  if ((index < 0) || (index >= m_descriptions.Length()))
     return NS_ERROR_FAILURE;
 
   *_retval = ToNewUnicode(*((nsString *)m_descriptions.ElementAt(index)));
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImportFieldMap::SetFieldMapSize(int32_t size)
 {
--- a/mailnews/import/src/nsImportFieldMap.h
+++ b/mailnews/import/src/nsImportFieldMap.h
@@ -4,17 +4,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsImportFieldMap_h___
 #define nsImportFieldMap_h___
 
 #include "nscore.h"
 #include "nsIImportFieldMap.h"
 #include "nsIAddrDatabase.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
+#include "nsString.h"
 
 
 ////////////////////////////////////////////////////////////////////////
 
 class nsIStringBundle;
 
 class nsImportFieldMap : public nsIImportFieldMap
 {
@@ -31,15 +32,15 @@ private:
   virtual ~nsImportFieldMap();
   nsresult  Allocate(int32_t newSize);
 
 private:
   int32_t    m_numFields;
   int32_t  *  m_pFields;
   bool *  m_pActive;
   int32_t    m_allocated;
-  nsVoidArray  m_descriptions;
+  nsTArray<nsString*>  m_descriptions;
   int32_t    m_mozFieldCount;
   bool        m_skipFirstRecord;
 };
 
 
 #endif
--- a/mailnews/local/public/nsIPop3Protocol.idl
+++ b/mailnews/local/public/nsIPop3Protocol.idl
@@ -1,24 +1,25 @@
 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-[ptr] native nsVoidArray(nsVoidArray);
+[ptr] native nsPop3UidlEntryArrayRef(nsTArray<Pop3UidlEntry*>);
 
 %{C++
-#include "nsVoidArray.h"
+#include "nsTArray.h"
+struct Pop3UidlEntry;
 %}
 
-[scriptable, uuid(aebda729-c423-4113-ae36-2229fdc3b699)]
+[scriptable, uuid(f3e1c1e8-3005-4554-9d46-595b1713a3a6)]
 interface nsIPop3Protocol : nsISupports {
   /* aUidl is an array of pointers to Pop3UidlEntry's. That structure is
    * currently defined in nsPop3Protocol.h, perhaps it should be here
    * instead...
    */
-  [noscript] void markMessages(in nsVoidArray aUidl);
+  [noscript] void markMessages(in nsPop3UidlEntryArrayRef aUidl);
   boolean checkMessage(in string aUidl);
 };
 
 
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -842,77 +842,77 @@ NS_IMETHODIMP nsParseMailMessageState::G
     int32_t headerLen = strlen(curHeader);
     curHeader += headerLen + 1;
     headerPos += headerLen + 1;
   }
   *pHeaders = ToNewCString(crlfHeaders);
   return NS_OK;
 }
 
-struct message_header *nsParseMailMessageState::GetNextHeaderInAggregate (nsVoidArray &list)
+struct message_header *nsParseMailMessageState::GetNextHeaderInAggregate (nsTArray<struct message_header*> &list)
 {
   // When parsing a message with multiple To or CC header lines, we're storing each line in a
   // list, where the list represents the "aggregate" total of all the header. Here we get a new
   // line for the list
 
   struct message_header *header = (struct message_header*) PR_Calloc (1, sizeof(struct message_header));
   list.AppendElement (header);
   return header;
 }
 
-void nsParseMailMessageState::GetAggregateHeader (nsVoidArray &list, struct message_header *outHeader)
+void nsParseMailMessageState::GetAggregateHeader (nsTArray<struct message_header*> &list, struct message_header *outHeader)
 {
   // When parsing a message with multiple To or CC header lines, we're storing each line in a
   // list, where the list represents the "aggregate" total of all the header. Here we combine
   // all the lines together, as though they were really all found on the same line
 
   struct message_header *header = nullptr;
   int length = 0;
   int i;
 
   // Count up the bytes required to allocate the aggregated header
-  for (i = 0; i < list.Count(); i++)
+  for (i = 0; i < list.Length(); i++)
   {
-    header = (struct message_header*) list.ElementAt(i);
+    header = list.ElementAt(i);
     length += (header->length + 1); //+ for ","
   }
 
   if (length > 0)
   {
     char *value = (char*) PR_CALLOC (length + 1); //+1 for null term
     if (value)
     {
       // Catenate all the To lines together, separated by commas
       value[0] = '\0';
-      int size = list.Count();
+      int size = list.Length();
       for (i = 0; i < size; i++)
       {
-        header = (struct message_header*) list.ElementAt(i);
+        header = list.ElementAt(i);
         PL_strncat (value, header->value, header->length);
         if (i + 1 < size)
           PL_strcat (value, ",");
       }
       outHeader->length = length;
       outHeader->value = value;
     }
   }
   else
   {
     outHeader->length = 0;
     outHeader->value = nullptr;
   }
 }
 
-void nsParseMailMessageState::ClearAggregateHeader (nsVoidArray &list)
+void nsParseMailMessageState::ClearAggregateHeader (nsTArray<struct message_header*> &list)
 {
   // Reset the aggregate headers. Free only the message_header struct since
   // we don't own the value pointer
 
-  for (int i = 0; i < list.Count(); i++)
-    PR_Free ((struct message_header*) list.ElementAt(i));
+  for (int i = 0; i < list.Length(); i++)
+    PR_Free (list.ElementAt(i));
   list.Clear();
 }
 
 // We've found a new envelope to parse.
 nsresult nsParseMailMessageState::StartNewEnvelope(const char *line, uint32_t lineLength)
 {
   m_envelope_pos = m_position;
   m_state = nsIMsgParseMailMsgState::ParseHeadersState;
--- a/mailnews/local/src/nsParseMailbox.h
+++ b/mailnews/local/src/nsParseMailbox.h
@@ -21,17 +21,17 @@
 #include "nsIWeakReferenceUtils.h"
 #include "nsIMsgWindow.h"
 #include "nsImapMoveCoalescer.h"
 #include "nsAutoPtr.h"
 #include "nsStringGlue.h"
 #include "nsIMsgFilterList.h"
 #include "nsIMsgFilterHitNotify.h"
 #include "nsIMsgFolderNotificationService.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 
 class nsByteArray;
 class nsOutputFileStream;
 class nsIOFileStream;
 class nsInputFileStream;
 class nsIMsgFilter;
 class MSG_FolderInfoMail;
 class nsIMsgFilterList;
@@ -90,21 +90,21 @@ public:
   struct message_header m_mozstatus;
   struct message_header m_mozstatus2;
   struct message_header m_in_reply_to;
   struct message_header m_replyTo;
   struct message_header m_content_type;
   struct message_header m_bccList;
 
   // Support for having multiple To or Cc header lines in a message
-  nsVoidArray m_toList;
-  nsVoidArray m_ccList;
-  struct message_header *GetNextHeaderInAggregate (nsVoidArray &list);
-  void GetAggregateHeader (nsVoidArray &list, struct message_header *);
-  void ClearAggregateHeader (nsVoidArray &list);
+  nsTArray<struct message_header*> m_toList;
+  nsTArray<struct message_header*> m_ccList;
+  struct message_header *GetNextHeaderInAggregate (nsTArray<struct message_header*> &list);
+  void GetAggregateHeader (nsTArray<struct message_header*> &list, struct message_header *);
+  void ClearAggregateHeader (nsTArray<struct message_header*> &list);
 
   struct message_header m_envelope_from;
   struct message_header m_envelope_date;
   struct message_header m_priority;
   struct message_header m_account_key;
   struct message_header m_keywords;
   // Mdn support
   struct message_header m_mdn_original_recipient;
--- a/mailnews/local/src/nsPop3IncomingServer.cpp
+++ b/mailnews/local/src/nsPop3IncomingServer.cpp
@@ -643,20 +643,20 @@ NS_IMETHODIMP nsPop3IncomingServer::Mark
 
     GetLocalPath(getter_AddRefs(localPath));
 
     GetHostName(hostName);
     GetUsername(userName);
     // do it all in one fell swoop
     rv = nsPop3Protocol::MarkMsgForHost(hostName.get(), userName.get(), localPath, m_uidlsToMark);
   }
-  uint32_t count = m_uidlsToMark.Count();
+  uint32_t count = m_uidlsToMark.Length();
   for (uint32_t i = 0; i < count; i++)
   {
-    Pop3UidlEntry *ue = static_cast<Pop3UidlEntry*>(m_uidlsToMark[i]);
+    Pop3UidlEntry *ue = m_uidlsToMark[i];
     PR_Free(ue->uidl);
     PR_Free(ue);
   }
   m_uidlsToMark.Clear();
   return rv;
 }
 
 NS_IMPL_ISUPPORTS(nsPop3GetMailChainer, nsIUrlListener)
--- a/mailnews/local/src/nsPop3IncomingServer.h
+++ b/mailnews/local/src/nsPop3IncomingServer.h
@@ -46,12 +46,12 @@ protected:
   virtual ~nsPop3IncomingServer();
   nsresult GetInbox(nsIMsgWindow *msgWindow, nsIMsgFolder **inbox);
 
 private:
   uint32_t m_capabilityFlags;
   bool m_authenticated;
   nsCOMPtr <nsIPop3Protocol> m_runningProtocol;
   nsCOMPtr <nsIMsgFolder> m_rootMsgFolder;
-  nsVoidArray m_uidlsToMark;
+  nsTArray<Pop3UidlEntry*> m_uidlsToMark;
 };
 
 #endif
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -396,32 +396,31 @@ void nsPop3Protocol::MarkMsgInHashTable(
     }
   }
 }
 
 /* static */
 nsresult
 nsPop3Protocol::MarkMsgForHost(const char *hostName, const char *userName,
                                       nsIFile *mailDirectory,
-                                       nsVoidArray &UIDLArray)
+                                       nsTArray<Pop3UidlEntry*> &UIDLArray)
 {
   if (!hostName || !userName || !mailDirectory)
     return NS_ERROR_NULL_POINTER;
 
   Pop3UidlHost *uidlHost = net_pop3_load_state(hostName, userName, mailDirectory);
   if (!uidlHost)
     return NS_ERROR_OUT_OF_MEMORY;
 
   bool changed = false;
 
-  uint32_t count = UIDLArray.Count();
+  uint32_t count = UIDLArray.Length();
   for (uint32_t i = 0; i < count; i++)
   {
-    MarkMsgInHashTable(uidlHost->hash,
-      static_cast<Pop3UidlEntry*>(UIDLArray[i]), &changed);
+    MarkMsgInHashTable(uidlHost->hash, UIDLArray[i], &changed);
   }
 
   if (changed)
     net_pop3_write_state(uidlHost, mailDirectory);
   net_pop3_free_state(uidlHost);
   return NS_OK;
 }
 
@@ -4074,28 +4073,28 @@ nsresult nsPop3Protocol::ProcessProtocol
     }
 
   }  /* end while */
 
   return NS_OK;
 
 }
 
-NS_IMETHODIMP nsPop3Protocol::MarkMessages(nsVoidArray *aUIDLArray)
+NS_IMETHODIMP nsPop3Protocol::MarkMessages(nsTArray<Pop3UidlEntry*> *aUIDLArray)
 {
   NS_ENSURE_ARG_POINTER(aUIDLArray);
-  uint32_t count = aUIDLArray->Count();
+  uint32_t count = aUIDLArray->Length();
 
   for (uint32_t i = 0; i < count; i++)
   {
     bool changed;
     if (m_pop3ConData->newuidl)
-      MarkMsgInHashTable(m_pop3ConData->newuidl, static_cast<Pop3UidlEntry*>(aUIDLArray->ElementAt(i)), &changed);
+      MarkMsgInHashTable(m_pop3ConData->newuidl, aUIDLArray->ElementAt(i), &changed);
     if (m_pop3ConData->uidlinfo)
-      MarkMsgInHashTable(m_pop3ConData->uidlinfo->hash, static_cast<Pop3UidlEntry*>(aUIDLArray->ElementAt(i)), &changed);
+      MarkMsgInHashTable(m_pop3ConData->uidlinfo->hash, aUIDLArray->ElementAt(i), &changed);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPop3Protocol::CheckMessage(const char *aUidl, bool *aBool)
 {
   Pop3UidlEntry *uidlEntry = nullptr;
 
--- a/mailnews/local/src/nsPop3Protocol.h
+++ b/mailnews/local/src/nsPop3Protocol.h
@@ -273,17 +273,17 @@ public:
   NS_IMETHOD OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus) override;
   NS_IMETHOD Cancel(nsresult status) override;
 
   static void MarkMsgInHashTable(PLHashTable *hashTable, const Pop3UidlEntry *uidl,
                                   bool *changed);
 
   static nsresult MarkMsgForHost(const char *hostName, const char *userName,
                                       nsIFile *mailDirectory,
-                                      nsVoidArray  &UIDLArray);
+                                      nsTArray<Pop3UidlEntry*> &UIDLArray);
 private:
   virtual ~nsPop3Protocol();
   nsCString m_ApopTimestamp;
   nsCOMPtr<nsIStringBundle> mLocalBundle;
 
   nsCString m_username;
   nsCString m_senderInfo;
   nsCString m_commandResponse;
--- a/mailnews/mime/emitters/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/nsMimeBaseEmitter.cpp
@@ -55,21 +55,21 @@ nsMimeBaseEmitter::nsMimeBaseEmitter()
   // Display output control vars...
   mDocHeader = false;
   m_stringBundle = nullptr;
   mURL = nullptr;
   mHeaderDisplayType = nsMimeHeaderDisplayTypes::NormalHeaders;
 
   // Setup array for attachments
   mAttachCount = 0;
-  mAttachArray = new nsVoidArray();
+  mAttachArray = new nsTArray<attachmentInfoType*>();
   mCurrentAttachment = nullptr;
 
   // Header cache...
-  mHeaderArray = new nsVoidArray();
+  mHeaderArray = new nsTArray<headerInfoType*>();
 
   // Embedded Header Cache...
   mEmbeddedHeaderArray = nullptr;
 
   // HTML Header Data...
 //  mHTMLHeaders = "";
 //  mCharset = "";
 
@@ -98,17 +98,17 @@ nsMimeBaseEmitter::~nsMimeBaseEmitter(vo
   {
     delete mBufferMgr;
     mBufferMgr = nullptr;
   }
 
   // Clean up the attachment array structures...
   if (mAttachArray)
   {
-    for (i=0; i<mAttachArray->Count(); i++)
+    for (i=0; i<mAttachArray->Length(); i++)
     {
       attachmentInfoType *attachInfo = (attachmentInfoType *)mAttachArray->ElementAt(i);
       if (!attachInfo)
         continue;
 
       PR_FREEIF(attachInfo->contentType);
       if (attachInfo->displayName)
         NS_Free(attachInfo->displayName);
@@ -128,24 +128,24 @@ nsMimeBaseEmitter::~nsMimeBaseEmitter(vo
 
 NS_IMETHODIMP nsMimeBaseEmitter::GetInterface(const nsIID & aIID, void * *aInstancePtr)
 {
   NS_ENSURE_ARG_POINTER(aInstancePtr);
   return QueryInterface(aIID, aInstancePtr);
 }
 
 void
-nsMimeBaseEmitter::CleanupHeaderArray(nsVoidArray *aArray)
+nsMimeBaseEmitter::CleanupHeaderArray(nsTArray<headerInfoType*> *aArray)
 {
   if (!aArray)
     return;
 
-  for (int32_t i=0; i<aArray->Count(); i++)
+  for (int32_t i=0; i<aArray->Length(); i++)
   {
-    headerInfoType *headerInfo = (headerInfoType *)aArray->ElementAt(i);
+    headerInfoType *headerInfo = aArray->ElementAt(i);
     if (!headerInfo)
       continue;
 
     PR_FREEIF(headerInfo->name);
     PR_FREEIF(headerInfo->value);
     PR_FREEIF(headerInfo);
   }
 
@@ -497,24 +497,24 @@ nsMimeBaseEmitter::WriteHelper(const nsA
 //
 // Find a cached header! Note: Do NOT free this value!
 //
 const char *
 nsMimeBaseEmitter::GetHeaderValue(const char  *aHeaderName)
 {
   int32_t     i;
   char        *retVal = nullptr;
-  nsVoidArray *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
+  nsTArray<headerInfoType*> *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
 
   if (!array)
     return nullptr;
 
-  for (i = 0; i < array->Count(); i++)
+  for (i = 0; i < array->Length(); i++)
   {
-    headerInfoType *headerInfo = (headerInfoType *)array->ElementAt(i);
+    headerInfoType *headerInfo = array->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) )
       continue;
 
     if (!PL_strcasecmp(aHeaderName, headerInfo->name))
     {
       retVal = headerInfo->value;
       break;
     }
@@ -542,17 +542,17 @@ nsMimeBaseEmitter::StartHeader(bool root
   // If this is not the mail messages header, then we need to create
   // the mEmbeddedHeaderArray structure for use with this internal header
   // structure.
   if (!mDocHeader)
   {
     if (mEmbeddedHeaderArray)
       CleanupHeaderArray(mEmbeddedHeaderArray);
 
-    mEmbeddedHeaderArray = new nsVoidArray();
+    mEmbeddedHeaderArray = new nsTArray<headerInfoType*>();
     NS_ENSURE_TRUE(mEmbeddedHeaderArray, NS_ERROR_OUT_OF_MEMORY);
   }
 
   // If the main doc, check on updated character set
   if (mDocHeader)
     UpdateCharacterSet(outCharset);
   CopyASCIItoUTF16(nsDependentCString(outCharset), mCharset);
   return NS_OK;
@@ -610,17 +610,17 @@ nsMimeBaseEmitter::UpdateCharacterSet(co
 // internal body or the outer message.
 //
 NS_IMETHODIMP
 nsMimeBaseEmitter::AddHeaderField(const char *field, const char *value)
 {
   if ( (!field) || (!value) )
     return NS_OK;
 
-  nsVoidArray   *tPtr;
+  nsTArray<headerInfoType*>  *tPtr;
   if (mDocHeader)
     tPtr = mHeaderArray;
   else
     tPtr = mEmbeddedHeaderArray;
 
   // This is a header so we need to cache and output later.
   // Ok, now we will setup the header info for the header array!
   headerInfoType  *ptr = (headerInfoType *) PR_NEWZAP(headerInfoType);
@@ -981,23 +981,23 @@ nsMimeBaseEmitter::DumpToCC()
 
   return NS_OK;
 }
 
 nsresult
 nsMimeBaseEmitter::DumpRestOfHeaders()
 {
   int32_t     i;
-  nsVoidArray *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
+  nsTArray<headerInfoType*> *array = mDocHeader? mHeaderArray : mEmbeddedHeaderArray;
 
   mHTMLHeaders.Append("<table border=0 cellspacing=0 cellpadding=0 width=\"100%\" class=\"header-part3\">");
 
-  for (i = 0; i < array->Count(); i++)
+  for (i = 0; i < array->Length(); i++)
   {
-    headerInfoType *headerInfo = (headerInfoType *)array->ElementAt(i);
+    headerInfoType *headerInfo = array->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) ||
       (!headerInfo->value) || (!(*headerInfo->value)))
       continue;
 
     if ( (!PL_strcasecmp(HEADER_SUBJECT, headerInfo->name)) ||
       (!PL_strcasecmp(HEADER_DATE, headerInfo->name)) ||
       (!PL_strcasecmp(HEADER_FROM, headerInfo->name)) ||
       (!PL_strcasecmp(HEADER_TO, headerInfo->name)) ||
--- a/mailnews/mime/emitters/nsMimeBaseEmitter.h
+++ b/mailnews/mime/emitters/nsMimeBaseEmitter.h
@@ -13,17 +13,17 @@
 #include "nsIOutputStream.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIURI.h"
 #include "nsIChannel.h"
 #include "nsIMimeMiscStatus.h"
 #include "nsIPipe.h"
 #include "nsIStringBundle.h"
 #include "nsCOMPtr.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsIMimeConverter.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDateTimeFormat.h"
 
 //
 // The base emitter will serve as the place to do all of the caching,
 // sorting, etc... of mail headers and bodies for this internally developed
@@ -76,17 +76,17 @@ public:
   // To write out a stored header array as HTML
   virtual nsresult            WriteHeaderFieldHTMLPrefix(const nsACString &name);
   virtual nsresult            WriteHeaderFieldHTML(const char *field, const char *value);
   virtual nsresult            WriteHeaderFieldHTMLPostfix();
 
 protected:
   virtual ~nsMimeBaseEmitter();
   // Internal methods...
-  void                CleanupHeaderArray(nsVoidArray *aArray);
+  void                CleanupHeaderArray(nsTArray<headerInfoType*> *aArray);
 
   // For header output...
   nsresult            DumpSubjectFromDate();
   nsresult            DumpToCC();
   nsresult            DumpRestOfHeaders();
   nsresult            OutputGenericHeader(const char *aHeaderVal);
 
   nsresult            WriteHelper(const nsACString &buf, uint32_t *countWritten);
@@ -114,22 +114,22 @@ protected:
   // Output control and info...
   bool                mDocHeader;         // For header determination...
   nsIURI              *mURL;              // the url for the data being processed...
   int32_t             mHeaderDisplayType; // The setting for header output...
   nsCString           mHTMLHeaders;       // HTML Header Data...
 
   // For attachment processing...
   int32_t             mAttachCount;
-  nsVoidArray         *mAttachArray;
+  nsTArray<attachmentInfoType*>  *mAttachArray;
   attachmentInfoType  *mCurrentAttachment;
 
   // For header caching...
-  nsVoidArray         *mHeaderArray;
-  nsVoidArray         *mEmbeddedHeaderArray;
+  nsTArray<headerInfoType*>  *mHeaderArray;
+  nsTArray<headerInfoType*>  *mEmbeddedHeaderArray;
 
   // For body caching...
   bool                mBodyStarted;
   nsCString           mBody;
   bool                mFirstHeaders;
 
   // For the format being used...
   int32_t             mFormat;
--- a/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
+++ b/mailnews/mime/emitters/nsMimeHtmlEmitter.cpp
@@ -179,19 +179,19 @@ nsresult nsMimeHtmlDisplayEmitter::Broad
     // todo - should make this upper case
     if (!extraExpandedHeaders.IsEmpty())
     {
       ToLowerCase(extraExpandedHeaders);
       ParseString(extraExpandedHeaders, ' ', extraExpandedHeadersArray);
     }
   }
 
-  for (int32_t i=0; i<mHeaderArray->Count(); i++)
+  for (int32_t i=0; i<mHeaderArray->Length(); i++)
   {
-    headerInfoType * headerInfo = (headerInfoType *) mHeaderArray->ElementAt(i);
+    headerInfoType * headerInfo = mHeaderArray->ElementAt(i);
     if ( (!headerInfo) || (!headerInfo->name) || (!(*headerInfo->name)) || (!headerInfo->value) || (!(*headerInfo->value)))
       continue;
 
     const char * headerValue = headerInfo->value;
 
     // optimization: if we aren't in view all header view mode, we only show a small set of the total # of headers.
     // don't waste time sending those out to the UI since the UI is going to ignore them anyway.
     if (aHeaderMode != VIEW_ALL_HEADERS && (mFormat != nsMimeOutput::nsMimeMessageFilterSniffer))
@@ -246,19 +246,19 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::
       mFormat = nsMimeOutput::nsMimeMessagePrintOutput;
 
     return nsMimeBaseEmitter::WriteHTMLHeaders(name);
   }
   else
     mFirstHeaders = false;
 
   bool bFromNewsgroups = false;
-  for (int32_t j=0; j < mHeaderArray->Count(); j++)
+  for (int32_t j=0; j < mHeaderArray->Length(); j++)
   {
-    headerInfoType *headerInfo = (headerInfoType *)mHeaderArray->ElementAt(j);
+    headerInfoType *headerInfo = mHeaderArray->ElementAt(j);
     if (!(headerInfo && headerInfo->name && *headerInfo->name))
       continue;
 
     if (!PL_strcasecmp("Newsgroups", headerInfo->name))
     {
       bFromNewsgroups = true;
       break;
     }
--- a/mailnews/mime/src/mimei.cpp
+++ b/mailnews/mime/src/mimei.cpp
@@ -57,17 +57,17 @@
 #include "nsIServiceManager.h"
 #include "mimemoz2.h"
 #include "nsIMimeContentTypeHandler.h"
 #include "nsIComponentManager.h"
 #include "nsCategoryManagerUtils.h"
 #include "nsXPCOMCID.h"
 #include "nsISimpleMimeConverter.h"
 #include "nsSimpleMimeConverterStub.h"
-#include "nsVoidArray.h"
+#include "nsTArray.h"
 #include "nsMimeStringResources.h"
 #include "nsMimeTypes.h"
 #include "nsMsgUtils.h"
 #include "nsIPrefBranch.h"
 #include "imgLoader.h"
 
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgHdr.h"
@@ -88,75 +88,58 @@ static int mime_classinit(MimeObjectClas
  * These are the necessary defines/variables for doing
  * content type handlers in external plugins.
  */
 typedef struct {
   char        content_type[128];
   bool        force_inline_display;
 } cthandler_struct;
 
-nsVoidArray         *ctHandlerList = NULL;
-bool                foundIt = false;
-bool                force_display = false;
-
-bool
-EnumFunction(void* aElement, void *aData)
-{
-  cthandler_struct    *ptr = (cthandler_struct *) aElement;
-  char                *ctPtr = (char *)aData;
-
-  if ( (!aElement) || (!aData) )
-    return true;
-
-  if (PL_strcasecmp(ctPtr, ptr->content_type) == 0)
-  {
-    foundIt = true;
-    force_display = ptr->force_inline_display;
-    return false;
-  }
-
-  return true;
-}
+nsTArray<cthandler_struct*> *ctHandlerList = NULL;
 
 /*
  * This will return TRUE if the content_type is found in the
  * list, FALSE if it is not found.
  */
 bool
 find_content_type_attribs(const char *content_type,
                           bool       *force_inline_display)
 {
   *force_inline_display = false;
   if (!ctHandlerList)
     return false;
 
-  foundIt = false;
-  force_display = false;
-  ctHandlerList->EnumerateForwards(EnumFunction, (void *)content_type);
-  if (foundIt)
-    *force_inline_display = force_display;
+  for (size_t i = 0; i < ctHandlerList->Length(); i++) 
+  {
+    cthandler_struct *ptr = ctHandlerList->ElementAt(i);
+    if (PL_strcasecmp(content_type, ptr->content_type) == 0)
+    {
+      *force_inline_display = ptr->force_inline_display;
+      return true;
+    }
+  }
 
-  return (foundIt);
+  return false;
 }
 
 void
 add_content_type_attribs(const char *content_type,
                          contentTypeHandlerInitStruct  *ctHandlerInfo)
 {
   cthandler_struct    *ptr = NULL;
   bool                force_inline_display;
 
   if (find_content_type_attribs(content_type, &force_inline_display))
     return;
 
   if ( (!content_type) || (!ctHandlerInfo) )
     return;
 
   if (!ctHandlerList)
-    ctHandlerList = new nsVoidArray();
+    ctHandlerList = new nsTArray<cthandler_struct*>();
 
   if (!ctHandlerList)
     return;
 
   ptr = (cthandler_struct *) PR_MALLOC(sizeof(cthandler_struct));
   if (!ptr)
     return;