Bug 910989. Remove nsTHashtable::Init, fallible allocation, and MT hashtables. r=jcranmer,a=bustage-fix
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 06 Sep 2013 10:32:31 +0100
changeset 16466 ec3cd803c556650aac854e34fdb4e4ee2ecf87e2
parent 16465 dd53119788d828291985f9be14fff04842524d3a
child 16467 838cfd8efab4a9026a897dde45bd93aa2f876d9c
push id1019
push userbugzilla@standard8.plus.com
push dateMon, 28 Oct 2013 22:08:40 +0000
treeherdercomm-beta@c81d5f517a5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer, bustage-fix
bugs910989
Bug 910989. Remove nsTHashtable::Init, fallible allocation, and MT hashtables. r=jcranmer,a=bustage-fix
calendar/base/backend/libical/calICSService.h
ldap/xpcom/src/nsLDAPConnection.cpp
ldap/xpcom/src/nsLDAPConnection.h
ldap/xpcom/src/nsLDAPService.cpp
mailnews/addrbook/src/nsAbBSDirectory.cpp
mailnews/addrbook/src/nsAbCardProperty.cpp
mailnews/addrbook/src/nsAbLDAPDirectory.cpp
mailnews/addrbook/src/nsAbMDBDirectory.cpp
mailnews/addrbook/src/nsAbManager.cpp
mailnews/addrbook/src/nsAbOutlookDirectory.cpp
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgFolderCache.cpp
mailnews/base/src/nsMsgGroupView.cpp
mailnews/base/src/nsMsgSearchDBView.cpp
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/base/util/nsMsgTxn.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/imap/src/nsIMAPBodyShell.cpp
mailnews/imap/src/nsImapFlagAndUidState.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/import/oexpress/nsOEAddressIterator.cpp
mailnews/local/src/nsMsgBrkMBoxStore.cpp
mailnews/local/src/nsMsgMaildirStore.h
mailnews/mapi/mapihook/src/msgMapiMain.cpp
--- a/calendar/base/backend/libical/calICSService.h
+++ b/calendar/base/backend/libical/calICSService.h
@@ -102,22 +102,20 @@ class calIcalComponent : public calIIcal
                          public cal::XpcomBase
 {
     friend class calIcalProperty;
 public:
     calIcalComponent(icalcomponent *ical, calIIcalComponent *parent,
                      calITimezoneProvider *tzProvider = nullptr)
         : mComponent(ical), mTimezone(nullptr), mTzProvider(tzProvider), mParent(parent)
     {
-        mReferencedTimezones.Init();
     }
 
     // VTIMEZONE ctor
     calIcalComponent(icaltimezone * icaltz, icalcomponent * ical) : mComponent(ical), mTimezone(icaltz) {
-        mReferencedTimezones.Init();
     }
 
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSICLASSINFO
     NS_DECL_CALIICALCOMPONENT
 
 protected:
     virtual ~calIcalComponent();
--- a/ldap/xpcom/src/nsLDAPConnection.cpp
+++ b/ldap/xpcom/src/nsLDAPConnection.cpp
@@ -21,23 +21,27 @@
 #include "nsILDAPErrors.h"
 #include "nsIClassInfoImpl.h"
 #include "nsILDAPURL.h"
 #include "nsIObserverService.h"
 #include "mozilla/Services.h"
 #include "nsCRT.h"
 #include "nsLDAPUtils.h"
 
+using namespace mozilla;
+
 const char kConsoleServiceContractId[] = "@mozilla.org/consoleservice;1";
 const char kDNSServiceContractId[] = "@mozilla.org/network/dns-service;1";
 
 // constructor
 //
 nsLDAPConnection::nsLDAPConnection()
     : mConnectionHandle(0),
+      mPendingOperationsMutex("nsLDAPConnection.mPendingOperationsMutex"),
+      mPendingOperations(10),
       mSSL(false),
       mVersion(nsILDAPConnection::VERSION3),
       mDNSRequest(0)
 {
 }
 
 // destructor
 //
@@ -106,20 +110,16 @@ nsLDAPConnection::Init(nsILDAPURL *aUrl,
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t options;
   rv = aUrl->GetOptions(&options);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mSSL = options & nsILDAPURL::OPT_SECURE;
 
-  // Initialise the hashtable to keep track of pending operations.
-  // 10 buckets seems like a reasonable size.
-  mPendingOperations.Init(10);
-
   nsCOMPtr<nsIThread> curThread = do_GetCurrentThread();
   if (!curThread) {
     NS_ERROR("nsLDAPConnection::Init(): couldn't get current thread");
     return NS_ERROR_FAILURE;
   }
 
   // Do the pre-resolve of the hostname, using the DNS service. This
   // will also initialize the LDAP connection properly, once we have
@@ -220,27 +220,28 @@ GetListOfPendingOperations(const uint32_
 }
 
 NS_IMETHODIMP
 nsLDAPConnection::Observe(nsISupports *aSubject, const char *aTopic,
                           const PRUnichar *aData)
 {
   if (!nsCRT::strcmp(aTopic, "profile-change-net-teardown")) {
     // Abort all ldap requests.
-    if (mPendingOperations.Count() > 0) {
-      /* We cannot use enumerate function to abort operations because
-       * nsILDAPOperation::AbandonExt() is modifying list of operations
-       * and this leads to starvation.
-       * We have to do a copy of pending operations.
-       */
-      nsTArray<nsILDAPOperation*> pending_operations;
+    /* We cannot use enumerate function to abort operations because
+     * nsILDAPOperation::AbandonExt() is modifying list of operations
+     * and this leads to starvation.
+     * We have to do a copy of pending operations.
+     */
+    nsTArray<nsILDAPOperation*> pending_operations;
+    {
+      MutexAutoLock lock(mPendingOperationsMutex);
       mPendingOperations.EnumerateRead(GetListOfPendingOperations, (void *) (&pending_operations));
-      for (uint32_t i = 0; i < pending_operations.Length(); i++) {
-        pending_operations[i]->AbandonExt();
-      }
+    }
+    for (uint32_t i = 0; i < pending_operations.Length(); i++) {
+      pending_operations[i]->AbandonExt();
     }
     Close();
   } else {
     NS_NOTREACHED("unexpected topic");
     return NS_ERROR_UNEXPECTED;
   }
   return NS_OK;
 }
@@ -323,34 +324,36 @@ nsLDAPConnection::GetErrorString(PRUnich
  */
 nsresult
 nsLDAPConnection::AddPendingOperation(uint32_t aOperationID, nsILDAPOperation *aOperation)
 {
   NS_ENSURE_ARG_POINTER(aOperation);
 
   nsIRunnable* runnable = new nsLDAPConnectionRunnable(aOperationID, aOperation,
                                                        this);
-  mPendingOperations.Put((uint32_t)aOperationID, aOperation);
+  {
+    MutexAutoLock lock(mPendingOperationsMutex);
+    mPendingOperations.Put((uint32_t)aOperationID, aOperation);
+    PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
+           ("pending operation added; total pending operations now = %d\n",
+            mPendingOperations.Count()));
+  }
 
   nsresult rv;
   if (!mThread)
   {
     rv = NS_NewThread(getter_AddRefs(mThread), runnable);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   else
   {
     rv = mThread->Dispatch(runnable, nsIEventTarget::DISPATCH_NORMAL);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
-         ("pending operation added; total pending operations now = %d\n",
-          mPendingOperations.Count()));
-
   return NS_OK;
 }
 
 /**
  * Remove an nsILDAPOperation from the list of operations pending on this
  * connection.  Mainly intended for use by the nsLDAPOperation code.
  *
  * @param aOperation    operation to add
@@ -363,21 +366,24 @@ nsLDAPConnection::AddPendingOperation(ui
 nsresult
 nsLDAPConnection::RemovePendingOperation(uint32_t aOperationID)
 {
   NS_ENSURE_TRUE(aOperationID > 0, NS_ERROR_UNEXPECTED);
 
   PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
          ("nsLDAPConnection::RemovePendingOperation(): operation removed\n"));
 
-  mPendingOperations.Remove(aOperationID);
-  PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
-         ("nsLDAPConnection::RemovePendingOperation(): operation "
-          "removed; total pending operations now = %d\n",
-          mPendingOperations.Count()));
+  {
+    MutexAutoLock lock(mPendingOperationsMutex);
+    mPendingOperations.Remove(aOperationID);
+    PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
+           ("nsLDAPConnection::RemovePendingOperation(): operation "
+            "removed; total pending operations now = %d\n",
+            mPendingOperations.Count()));
+  }
 
   return NS_OK;
 }
 
 class nsOnLDAPMessageRunnable : public nsRunnable
 {
 public:
   nsOnLDAPMessageRunnable(nsLDAPMessage *aMsg, bool aClear)
@@ -421,33 +427,37 @@ nsLDAPConnection::InvokeMessageCallback(
 {
 #if defined(DEBUG)
   // We only want this being logged for debug builds so as not to affect performance too much.
   PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("InvokeMessageCallback entered\n"));
 #endif
 
   // Get the operation.
   nsCOMPtr<nsILDAPOperation> operation;
-  mPendingOperations.Get((uint32_t)aOperation, getter_AddRefs(operation));
+  {
+    MutexAutoLock lock(mPendingOperationsMutex);
+    mPendingOperations.Get((uint32_t)aOperation, getter_AddRefs(operation));
+  }
 
   NS_ENSURE_TRUE(operation, NS_ERROR_NULL_POINTER);
 
   nsLDAPMessage *msg = static_cast<nsLDAPMessage *>(aMsg);
   msg->mOperation = operation;
 
   // proxy the listener callback to the ui thread.
   nsRefPtr<nsOnLDAPMessageRunnable> runnable =
     new nsOnLDAPMessageRunnable(msg, aRemoveOpFromConnQ);
   // invoke the callback
   NS_DispatchToMainThread(runnable);
 
   // if requested (ie the operation is done), remove the operation
   // from the connection queue.
   if (aRemoveOpFromConnQ)
   {
+    MutexAutoLock lock(mPendingOperationsMutex);
     mPendingOperations.Remove(aOperation);
 
     PR_LOG(gLDAPLogModule, PR_LOG_DEBUG,
            ("pending operation removed; total pending operations now ="
             " %d\n", mPendingOperations.Count()));
   }
 
   return NS_OK;
@@ -680,17 +690,20 @@ NS_IMETHODIMP nsLDAPConnectionRunnable::
           //
           if (errorCode == LDAP_SASL_BIND_IN_PROGRESS) {
             struct berval *creds;
             ldap_parse_sasl_bind_result(
               mConnection->mConnectionHandle, msgHandle,
               &creds, 0);
 
             nsCOMPtr<nsILDAPOperation> operation;
-            mConnection->mPendingOperations.Get((uint32_t)mOperationID, getter_AddRefs(operation));
+            {
+              MutexAutoLock lock(mConnection->mPendingOperationsMutex);
+              mConnection->mPendingOperations.Get((uint32_t)mOperationID, getter_AddRefs(operation));
+            }
 
             NS_ENSURE_TRUE(operation, NS_ERROR_NULL_POINTER);
 
             nsresult rv = operation->SaslStep(creds->bv_val, creds->bv_len);
             if (NS_SUCCEEDED(rv))
               return NS_OK;
           }
           break;
--- a/ldap/xpcom/src/nsLDAPConnection.h
+++ b/ldap/xpcom/src/nsLDAPConnection.h
@@ -19,32 +19,34 @@
 #include "nsWeakReference.h"
 #include "nsWeakPtr.h"
 #include "nsIDNSListener.h"
 #include "nsICancelable.h"
 #include "nsIRequest.h"
 #include "nsCOMArray.h"
 #include "nsIObserver.h"
 #include "nsAutoPtr.h"
+#include "mozilla/Mutex.h"
 
 // 0d871e30-1dd2-11b2-8ea9-831778c78e93
 //
 #define NS_LDAPCONNECTION_CID \
 { 0x0d871e30, 0x1dd2, 0x11b2, \
  { 0x8e, 0xa9, 0x83, 0x17, 0x78, 0xc7, 0x8e, 0x93 }}
 
 class nsLDAPConnection : public nsILDAPConnection,
                          public nsSupportsWeakReference,
                          public nsIDNSListener,
                          public nsIObserver
 
 {
     friend class nsLDAPOperation;
     friend class nsLDAPMessage;
     friend class nsLDAPConnectionRunnable;
+    typedef mozilla::Mutex Mutex;
 
   public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSILDAPCONNECTION
     NS_DECL_NSIDNSLISTENER
     NS_DECL_NSIOBSERVER
 
     // constructor & destructor
@@ -85,17 +87,18 @@ class nsLDAPConnection : public nsILDAPC
      */
     nsresult RemovePendingOperation(uint32_t aOperationID);
 
     void Close();                       // close the connection
     LDAP *mConnectionHandle;            // the LDAP C SDK's connection object
     nsCString mBindName;                // who to bind as
     nsCOMPtr<nsIThread> mThread;        // thread which marshals results
 
-    nsInterfaceHashtableMT<nsUint32HashKey, nsILDAPOperation> mPendingOperations;
+    Mutex mPendingOperationsMutex;
+    nsInterfaceHashtable<nsUint32HashKey, nsILDAPOperation> mPendingOperations;
 
     int32_t mPort;                      // The LDAP port we're binding to
     bool mSSL;                        // the options
     uint32_t mVersion;                  // LDAP protocol version
 
     nsCString mResolvedIP;              // Preresolved list of host IPs
     nsCOMPtr<nsILDAPMessageListener> mInitListener; // Init callback
     nsCOMPtr<nsICancelable> mDNSRequest;   // The "active" DNS request
--- a/ldap/xpcom/src/nsLDAPService.cpp
+++ b/ldap/xpcom/src/nsLDAPService.cpp
@@ -180,23 +180,20 @@ nsLDAPService::nsLDAPService()
 }
 
 // destructor
 //
 nsLDAPService::~nsLDAPService()
 {
 }
 
-// Initializer, create some internal hash tables etc.
+// Initializer
 //
 nsresult nsLDAPService::Init()
 {
-    mServers.Init();
-    mConnections.Init();
-
     return NS_OK;
 }
 
 // void addServer (in nsILDAPServer aServer);
 NS_IMETHODIMP nsLDAPService::AddServer(nsILDAPServer *aServer)
 {
     nsLDAPServiceEntry *entry;
     nsString key;
--- a/mailnews/addrbook/src/nsAbBSDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbBSDirectory.cpp
@@ -16,18 +16,18 @@
 #include "nsAbMDBDirFactory.h"
 #include "nsArrayEnumerator.h"
 #include "nsVoidArray.h"
 
 #include "nsCRTGlue.h"
 
 nsAbBSDirectory::nsAbBSDirectory()
 : mInitialized(false)
+, mServers(13)
 {
-  mServers.Init(13);
 }
 
 nsAbBSDirectory::~nsAbBSDirectory()
 {
 }
 
 NS_IMETHODIMP nsAbBSDirectory::Init(const char *aURI)
 {
--- a/mailnews/addrbook/src/nsAbCardProperty.cpp
+++ b/mailnews/addrbook/src/nsAbCardProperty.cpp
@@ -102,18 +102,16 @@ static const AppendItem CHAT_ATTRS_ARRAY
   {kICQProperty, "propertyICQ", eAppendLabel},
   {kXMPPProperty, "propertyXMPP", eAppendLabel},
   {kIRCProperty, "propertyIRC", eAppendLabel}
 };
 
 nsAbCardProperty::nsAbCardProperty()
   : m_IsMailList(false)
 {
-  m_properties.Init();
-
   // Initialize some default properties
   SetPropertyAsUint32(kPreferMailFormatProperty, nsIAbPreferMailFormat::unknown);
   SetPropertyAsUint32(kPopularityIndexProperty, 0);
   // Uninitialized...
   SetPropertyAsUint32(kLastModifiedDateProperty, 0);
   SetPropertyAsBool(kAllowRemoteContentProperty, false);
 }
 
--- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp
@@ -39,17 +39,16 @@
 using namespace mozilla;
 
 nsAbLDAPDirectory::nsAbLDAPDirectory() :
   nsAbDirProperty(),
   mPerformingQuery(false),
   mContext(0),
   mLock("nsAbLDAPDirectory.mLock")
 {
-  mCache.Init();
 }
 
 nsAbLDAPDirectory::~nsAbLDAPDirectory()
 {
 }
 
 NS_IMPL_ISUPPORTS_INHERITED3(nsAbLDAPDirectory, nsAbDirProperty,
                              nsISupportsWeakReference, nsIAbDirSearchListener,
--- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp
@@ -28,17 +28,16 @@
 #include "nsMemory.h"
 #include "nsArrayUtils.h"
 #include "nsUnicharUtils.h"
 
 nsAbMDBDirectory::nsAbMDBDirectory(void):
      nsAbMDBDirProperty(),
      mPerformingQuery(false)
 {
-  mSearchCache.Init();
 }
 
 nsAbMDBDirectory::~nsAbMDBDirectory(void)
 {
   if (mDatabase) {
     mDatabase->RemoveListener(this);
   }
 }
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -117,17 +117,16 @@ const ExportAttributesTableStruct EXPORT
   {kFamilyNameProperty},
 };
 
 //
 // nsAbManager
 //
 nsAbManager::nsAbManager()
 {
-  mAbStore.Init();
 }
 
 nsAbManager::~nsAbManager()
 {
 }
 
 NS_IMPL_ISUPPORTS3(nsAbManager, nsIAbManager, nsICommandLineHandler,
   nsIObserver)
--- a/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbOutlookDirectory.cpp
@@ -49,19 +49,16 @@ nsAbOutlookDirectory::~nsAbOutlookDirect
 }
 
 NS_IMPL_ISUPPORTS_INHERITED3(nsAbOutlookDirectory, nsAbDirProperty,
                              nsIAbDirectoryQuery, nsIAbDirectorySearch,
                              nsIAbDirSearchListener)
 
 NS_IMETHODIMP nsAbOutlookDirectory::Init(const char *aUri)
 {
-  mQueryThreads.Init();
-  mCardList.Init();
-
   nsresult rv = nsAbDirProperty::Init(aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString entry;
   nsAutoCString stub;
 
   mAbWinType = getAbWinType(kOutlookDirectoryScheme, mURINoQuery.get(), stub, entry);
   if (mAbWinType == nsAbWinType_Unknown) {
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -98,17 +98,16 @@ static void openMailWindow(const nsACStr
   }
 }
 
 nsMessengerUnixIntegration::nsMessengerUnixIntegration()
 {
   mBiffStateAtom = MsgGetAtom("BiffState");
   mNewMailReceivedAtom = MsgGetAtom("NewMailReceived");
   mAlertInProgress = false;
-  mLastMRUTimes.Init();
   mFoldersWithNewMail = do_CreateInstance(NS_ARRAY_CONTRACTID);
 }
 
 NS_IMPL_ISUPPORTS4(nsMessengerUnixIntegration, nsIFolderListener, nsIObserver,
                    nsIMessengerOSIntegration, nsIUrlListener)
 
 nsresult
 nsMessengerUnixIntegration::Init()
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -152,19 +152,16 @@ nsMsgAccountManager::~nsMsgAccountManage
 
 nsresult nsMsgAccountManager::Init()
 {
   nsresult rv;
 
   m_prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  m_identities.Init();
-  m_incomingServers.Init();
-
   nsCOMPtr<nsIObserverService> observerService =
            mozilla::services::GetObserverService();
   if (observerService)
   {
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, true);
     observerService->AddObserver(this, "quit-application-granted" , true);
     observerService->AddObserver(this, ABOUT_TO_GO_OFFLINE_TOPIC, true);
     observerService->AddObserver(this, "profile-before-change", true);
--- a/mailnews/base/src/nsMsgFolderCache.cpp
+++ b/mailnews/base/src/nsMsgFolderCache.cpp
@@ -228,18 +228,16 @@ nsresult nsMsgFolderCache::OpenMDB(const
   }
   return ret;
 }
 
 NS_IMETHODIMP nsMsgFolderCache::Init(nsIFile *aFile)
 {
   NS_ENSURE_ARG_POINTER(aFile);
 
-  m_cacheElements.Init();
-
   bool exists;
   aFile->Exists(&exists);
 
   nsAutoCString dbPath;
   aFile->GetNativePath(dbPath);
   // ### evil cast until MDB supports file streams.
   nsresult rv = OpenMDB(dbPath, exists);
   // if this fails and panacea.dat exists, try blowing away the db and recreating it
--- a/mailnews/base/src/nsMsgGroupView.cpp
+++ b/mailnews/base/src/nsMsgGroupView.cpp
@@ -18,17 +18,16 @@
 #define MSGHDR_CACHE_LOOK_AHEAD_SIZE  25    // Allocate this more to avoid reallocation on new mail.
 #define MSGHDR_CACHE_MAX_SIZE         8192  // Max msghdr cache entries.
 #define MSGHDR_CACHE_DEFAULT_SIZE     100
 
 nsMsgGroupView::nsMsgGroupView()
 {
   m_dayChanged = false;
   m_lastCurExplodedTime.tm_mday = 0;
-  m_groupsTable.Init();
 }
 
 nsMsgGroupView::~nsMsgGroupView()
 {
 }
 
 NS_IMETHODIMP nsMsgGroupView::Open(nsIMsgFolder *aFolder, nsMsgViewSortTypeValue aSortType, nsMsgViewSortOrderValue aSortOrder, nsMsgViewFlagsTypeValue aViewFlags, int32_t *aCount)
 {
--- a/mailnews/base/src/nsMsgSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgSearchDBView.cpp
@@ -27,18 +27,16 @@
 #include "nsServiceManagerUtils.h"
 
 static bool gReferenceOnlyThreading;
 
 nsMsgSearchDBView::nsMsgSearchDBView()
 {
   // don't try to display messages for the search pane.
   mSuppressMsgDisplay = true;
-  m_threadsTable.Init();
-  m_hdrsTable.Init();
   m_totalMessagesInView = 0;
   m_nextThreadId = 1;
 }
 
 nsMsgSearchDBView::~nsMsgSearchDBView()
 {	
 }
 
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -49,24 +49,24 @@
 #include "nsIMsgFilter.h"
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
 
 #define PORT_NOT_SET -1
 
 nsMsgIncomingServer::nsMsgIncomingServer():
     m_rootFolder(0),
+    m_downloadedHdrs(50),
     m_numMsgsDownloaded(0),
     m_biffState(nsIMsgFolder::nsMsgBiffState_Unknown),
     m_serverBusy(false),
     m_canHaveFilters(true),
     m_displayStartupPage(true),
     mPerformingBiff(false)
 { 
-  m_downloadedHdrs.Init(50);
 }
 
 nsMsgIncomingServer::~nsMsgIncomingServer()
 {
 }
 
 NS_IMPL_ISUPPORTS2(nsMsgIncomingServer, nsIMsgIncomingServer,
   nsISupportsWeakReference)
--- a/mailnews/base/util/nsMsgTxn.cpp
+++ b/mailnews/base/util/nsMsgTxn.cpp
@@ -31,17 +31,16 @@ nsMsgTxn::nsMsgTxn()
 }
 
 nsMsgTxn::~nsMsgTxn()
 {
 }
 
 nsresult nsMsgTxn::Init()
 {
-  mPropertyHash.Init();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgTxn::HasKey(const nsAString& name, bool *aResult)
 {
   *aResult = mPropertyHash.Get(name, nullptr);
   return NS_OK;
 }
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -154,17 +154,16 @@ nsresult nsMsgComposeService::Init()
     rv = observerService->AddObserver(this, "profile-do-change", true);
   }
 
   // Register some pref observer
   nsCOMPtr<nsIPrefBranch> pbi = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (pbi)
     rv = pbi->AddObserver(PREF_MAIL_COMPOSE_MAXRECYCLEDWINDOWS, this, true);
 
-  mOpenComposeWindows.Init();
   Reset();
 
   AddGlobalHtmlDomains();
   // Since the compose service should only be initialized once, we can
   // be pretty sure there aren't any existing compose windows open.
   MsgCleanupTempFiles("nsmail", "tmp");
   MsgCleanupTempFiles("nsemail", "html");
   MsgCleanupTempFiles("nscopy", "tmp");
--- a/mailnews/imap/src/nsIMAPBodyShell.cpp
+++ b/mailnews/imap/src/nsIMAPBodyShell.cpp
@@ -1200,18 +1200,18 @@ bool nsIMAPMessageHeaders::ShouldFetchIn
 static int
 imap_shell_cache_strcmp (const void *a, const void *b)
 {
   return PL_strcmp ((const char *) a, (const char *) b);
 }
 #endif
 
 nsIMAPBodyShellCache::nsIMAPBodyShellCache()
+: m_shellHash(20)
 {
-  m_shellHash.Init(20);
   m_shellList = new nsVoidArray();
 }
 
 /* static */ nsIMAPBodyShellCache *nsIMAPBodyShellCache::Create()
 {
   nsIMAPBodyShellCache *cache = new nsIMAPBodyShellCache();
   if (!cache || !cache->m_shellList)
     return NULL;
--- a/mailnews/imap/src/nsImapFlagAndUidState.cpp
+++ b/mailnews/imap/src/nsImapFlagAndUidState.cpp
@@ -74,36 +74,35 @@ NS_IMETHODIMP nsImapFlagAndUidState::Get
   return NS_OK;
 }
 
 /* amount to expand for imap entry flags when we need more */
 
 nsImapFlagAndUidState::nsImapFlagAndUidState(int32_t numberOfMessages)
   : fUids(numberOfMessages),
     fFlags(numberOfMessages),
+    m_customFlagsHash(10),
+    m_customAttributesHash(10),
     mLock("nsImapFlagAndUidState.mLock")
 {
   fSupportedUserFlags = 0;
   fNumberDeleted = 0;
   fPartialUIDFetch = true;
-  m_customFlagsHash.Init(10);
-  m_customAttributesHash.Init(10);  
 }
 
 /* static */PLDHashOperator nsImapFlagAndUidState::FreeCustomFlags(const uint32_t &aKey, char *aData,
                                         void *closure)
 {
   PR_Free(aData);
   return PL_DHASH_NEXT;
 }
 
 nsImapFlagAndUidState::~nsImapFlagAndUidState()
 {
-  if (m_customFlagsHash.IsInitialized())
-    m_customFlagsHash.EnumerateRead(FreeCustomFlags, nullptr);
+  m_customFlagsHash.EnumerateRead(FreeCustomFlags, nullptr);
 }
 
 NS_IMETHODIMP
 nsImapFlagAndUidState::OrSupportedUserFlags(uint16_t flags)
 {
   fSupportedUserFlags |= flags;
   return NS_OK;
 }
@@ -118,18 +117,17 @@ nsImapFlagAndUidState::GetSupportedUserF
 
 // we need to reset our flags, (re-read all) but chances are the memory allocation needed will be
 // very close to what we were already using
 
 NS_IMETHODIMP nsImapFlagAndUidState::Reset()
 {
   PR_CEnterMonitor(this);
   fNumberDeleted = 0;
-  if (m_customFlagsHash.IsInitialized())
-    m_customFlagsHash.EnumerateRead(FreeCustomFlags, nullptr);
+  m_customFlagsHash.EnumerateRead(FreeCustomFlags, nullptr);
   m_customFlagsHash.Clear();
   fUids.Clear();
   fFlags.Clear();
   fPartialUIDFetch = true;
   PR_CExitMonitor(this);
   return NS_OK;
 }
 
@@ -240,18 +238,16 @@ imapMessageFlagsType nsImapFlagAndUidSta
   imapMessageFlagsType retFlags = (*foundIt) ? fFlags[*ndx] : kNoImapMsgFlag;
   PR_CExitMonitor(this);
   return retFlags;
 }
 
 NS_IMETHODIMP nsImapFlagAndUidState::AddUidCustomFlagPair(uint32_t uid, const char *customFlag)
 {
   MutexAutoLock mon(mLock);
-  if (!m_customFlagsHash.IsInitialized())
-    return NS_ERROR_OUT_OF_MEMORY;
   char *ourCustomFlags;
   char *oldValue = nullptr;
   m_customFlagsHash.Get(uid, &oldValue);
   if (oldValue)
   {
   // we'll store multiple keys as space-delimited since space is not
   // a valid character in a keyword. First, we need to look for the
     // customFlag in the existing flags;
@@ -280,59 +276,51 @@ NS_IMETHODIMP nsImapFlagAndUidState::Add
   }
   m_customFlagsHash.Put(uid, ourCustomFlags);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapFlagAndUidState::GetCustomFlags(uint32_t uid, char **customFlags)
 {
   MutexAutoLock mon(mLock);
-  if (m_customFlagsHash.IsInitialized())
+  char *value = nullptr;
+  m_customFlagsHash.Get(uid, &value);
+  if (value)
   {
-    char *value = nullptr;
-    m_customFlagsHash.Get(uid, &value);
-    if (value)
-    {
-      *customFlags = NS_strdup(value);
-      return (*customFlags) ? NS_OK : NS_ERROR_FAILURE;
-    }
+    *customFlags = NS_strdup(value);
+    return (*customFlags) ? NS_OK : NS_ERROR_FAILURE;
   }
   *customFlags = nullptr;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapFlagAndUidState::ClearCustomFlags(uint32_t uid)
 {
   MutexAutoLock mon(mLock);
   m_customFlagsHash.Remove(uid);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapFlagAndUidState::SetCustomAttribute(uint32_t aUid,
                                                         const nsACString &aCustomAttributeName,
                                                         const nsACString &aCustomAttributeValue)
 {
-  if (!m_customAttributesHash.IsInitialized())
-    return NS_ERROR_OUT_OF_MEMORY;
   nsCString key;
   key.AppendInt((int64_t)aUid);
   key.Append(aCustomAttributeName);
   nsCString value;
   value.Assign(aCustomAttributeValue);
   m_customAttributesHash.Put(key, value);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapFlagAndUidState::GetCustomAttribute(uint32_t aUid,
                                                         const nsACString &aCustomAttributeName,
                                                         nsACString &aCustomAttributeValue)
 {
-  if (m_customAttributesHash.IsInitialized())
-  {
-    nsCString key;
-    key.AppendInt((int64_t)aUid);
-    key.Append(aCustomAttributeName);
-    nsCString val;
-    m_customAttributesHash.Get(key, &val);
-    aCustomAttributeValue.Assign(val);
-  }
+  nsCString key;
+  key.AppendInt((int64_t)aUid);
+  key.Append(aCustomAttributeName);
+  nsCString val;
+  m_customAttributesHash.Get(key, &val);
+  aCustomAttributeValue.Assign(val);
   return NS_OK;
 }
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -3117,18 +3117,17 @@ nsresult nsImapMailFolder::NormalEndHead
     // Check if this header corresponds to a pseudo header
     // we have from doing a pseudo-offline move and then downloading
     // the real header from the server. In that case, we notify
     // db/folder listeners that the pseudo-header has become the new
     // header, i.e., the key has changed.
     nsCString newMessageId;
     nsMsgKey pseudoKey = nsMsgKey_None;
     newMsgHdr->GetMessageId(getter_Copies(newMessageId));
-    if (m_pseudoHdrs.IsInitialized())
-      m_pseudoHdrs.Get(newMessageId, &pseudoKey);
+    m_pseudoHdrs.Get(newMessageId, &pseudoKey);
     if (notifier && pseudoKey != nsMsgKey_None)
     {
       notifier->NotifyMsgKeyChanged(pseudoKey, newMsgHdr);
       m_pseudoHdrs.Remove(newMessageId);
     }
     mDatabase->AddNewHdrToDB(newMsgHdr, true);
     if (notifier)
       notifier->NotifyMsgAdded(newMsgHdr);
@@ -3869,18 +3868,16 @@ NS_IMETHODIMP nsImapMailFolder::AddMoveR
   nsCOMPtr<nsIMsgDBHdr> pseudoHdr;
   rv = mDatabase->GetMsgHdrForKey(aMsgKey, getter_AddRefs(pseudoHdr));
   NS_ENSURE_SUCCESS(rv, rv);
   nsCString messageId;
   pseudoHdr->GetMessageId(getter_Copies(messageId));
   // err on the side of caution and ignore messages w/o messageid.
   if (messageId.IsEmpty())
     return NS_OK;
-  if (!m_pseudoHdrs.IsInitialized())
-    m_pseudoHdrs.Init(10);
   m_pseudoHdrs.Put(messageId, aMsgKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP nsImapMailFolder::StoreImapFlags(int32_t flags, bool addFlags,
                                                nsMsgKey *keys, uint32_t numKeys,
                                                nsIUrlListener *aUrlListener)
 {
@@ -6150,20 +6147,20 @@ NS_IMETHODIMP nsImapMailFolder::GetCanOp
 }
 
 ///////// nsMsgIMAPFolderACL class ///////////////////////////////
 
 // This string is defined in the ACL RFC to be "anyone"
 #define IMAP_ACL_ANYONE_STRING "anyone"
 
 nsMsgIMAPFolderACL::nsMsgIMAPFolderACL(nsImapMailFolder *folder)
+: m_rightsHash(24)
 {
   NS_ASSERTION(folder, "need folder");
   m_folder = folder;
-  m_rightsHash.Init(24);
   m_aclCount = 0;
   BuildInitialACLFromCache();
 }
 
 nsMsgIMAPFolderACL::~nsMsgIMAPFolderACL()
 {
 }
 
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -456,18 +456,16 @@ nsImapProtocol::nsImapProtocol() : nsMsg
   m_inputStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true /* allocate new lines */, false /* leave CRLFs on the returned string */);
   m_currentBiffState = nsIMsgFolder::nsMsgBiffState_Unknown;
   m_progressStringName.Truncate();
 
   // since these are embedded in the nsImapProtocol object, but passed
   // through proxied xpcom methods, just AddRef them here.
   m_hdrDownloadCache = new nsMsgImapHdrXferInfo();
   m_downloadLineCache = new nsMsgImapLineDownloadCache();
-  m_standardListMailboxes.Init(0);
-  m_specialXListMailboxes.Init(0);
 
   // subscription
   m_autoSubscribe = true;
   m_autoUnsubscribe = true;
   m_autoSubscribeOnOpen = true;
   m_deletableChildren = nullptr;
 
   mFolderLastModSeq = 0;
--- a/mailnews/import/oexpress/nsOEAddressIterator.cpp
+++ b/mailnews/import/oexpress/nsOEAddressIterator.cpp
@@ -77,17 +77,16 @@ static MAPIFields  gMapiFields[] = {
   { 11, 12, PR_HOME_ADDRESS_STREET},
   { 24, kNoMultiLine, PR_DEPARTMENT_NAME}
 };
 
 nsOEAddressIterator::nsOEAddressIterator(CWAB *pWab, nsIAddrDatabase *database)
 {
   m_pWab = pWab;
   m_database = database;
-  m_listRows.Init();
 }
 
 nsOEAddressIterator::~nsOEAddressIterator()
 {
 }
 
 nsresult nsOEAddressIterator::EnumUser(const PRUnichar * pName, LPENTRYID pEid, ULONG cbEid)
 {
--- a/mailnews/local/src/nsMsgBrkMBoxStore.cpp
+++ b/mailnews/local/src/nsMsgBrkMBoxStore.cpp
@@ -35,17 +35,16 @@
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "prprf.h"
 #include <cstdlib> // for std::abs(int/long)
 #include <cmath> // for std::abs(float/double)
 
 nsMsgBrkMBoxStore::nsMsgBrkMBoxStore()
 {
-  m_outputStreams.Init();
 }
 
 nsMsgBrkMBoxStore::~nsMsgBrkMBoxStore()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsMsgBrkMBoxStore, nsIMsgPluggableStore)
 
--- a/mailnews/local/src/nsMsgMaildirStore.h
+++ b/mailnews/local/src/nsMsgMaildirStore.h
@@ -7,17 +7,16 @@
    Class for handling Maildir stores.
 */
 
 #ifndef nsMsgMaildirStore_h__
 #define nsMsgMaildirStore_h__
 
 #include "nsMsgLocalStoreUtils.h"
 #include "nsIFile.h"
-#include "nsInterfaceHashtable.h"
 #include "nsMsgMessageFlags.h"
 
 class nsMsgMaildirStore MOZ_FINAL : public nsMsgLocalStoreUtils, nsIMsgPluggableStore
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIMSGPLUGGABLESTORE
 
--- a/mailnews/mapi/mapihook/src/msgMapiMain.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiMain.cpp
@@ -22,18 +22,16 @@ nsMAPIConfiguration *nsMAPIConfiguration
 
   return m_pSelfRef;
 }
 
 nsMAPIConfiguration::nsMAPIConfiguration()
 : m_nMaxSessions(MAX_SESSIONS)
 {
   m_Lock = PR_NewLock();
-  m_SessionMap.Init();
-  m_ProfileMap.Init();
 }
 
 nsMAPIConfiguration::~nsMAPIConfiguration()
 {
   if (m_Lock)
     PR_DestroyLock(m_Lock);
 }