Bug 696242 - Convert NS_RegisterStaticAtoms and nsCSSScanner::ReportUnexpectedParams to take an array-reference rather than a pointer and length, making it impossible to pass a pointer/length that are inconsistent. r=jwalden
authorJacob Holzinger <jake.holzinger@gmail.com>
Thu, 08 Mar 2012 18:22:57 -0800
changeset 91486 bd1bb076db6e306391d9f1df4ad10429c0c45dae
parent 91485 9d4c267630d43eaa0760a6cfe2c53f05b5a209d9
child 91487 55a14858a2b638375ab265a931293711a3b025ad
push idunknown
push userunknown
push dateunknown
reviewersjwalden
bugs696242
milestone13.0a1
Bug 696242 - Convert NS_RegisterStaticAtoms and nsCSSScanner::ReportUnexpectedParams to take an array-reference rather than a pointer and length, making it impossible to pass a pointer/length that are inconsistent. r=jwalden
content/base/public/nsContentUtils.h
content/base/src/nsGkAtoms.cpp
content/html/content/src/nsFormSubmission.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLTextAreaElement.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
editor/libeditor/html/nsEditProperty.cpp
editor/txtsvc/src/nsTextServicesDocument.cpp
gfx/thebes/gfxAtoms.cpp
layout/inspector/src/inDOMView.cpp
layout/style/nsCSSAnonBoxes.cpp
layout/style/nsCSSParser.cpp
layout/style/nsCSSPseudoClasses.cpp
layout/style/nsCSSPseudoElements.cpp
layout/style/nsCSSScanner.cpp
layout/style/nsCSSScanner.h
parser/html/nsHtml5Atoms.cpp
parser/html/nsHtml5TreeOperation.cpp
parser/htmlparser/src/nsHTMLTags.cpp
rdf/base/src/nsRDFContentSink.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsStaticAtom.h
xpcom/io/nsDirectoryService.cpp
xpcom/tests/MoreTestingAtoms.cpp
xpcom/tests/TestAtoms.cpp
xpcom/tests/TestingAtoms.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -843,21 +843,32 @@ public:
   static nsresult GetLocalizedString(PropertiesFile aFile,
                                      const char* aKey,
                                      nsXPIDLString& aResult);
 
   /**
    * Fill (with the parameters given) the localized string named |aKey| in
    * properties file |aFile|.
    */
+private:
   static nsresult FormatLocalizedString(PropertiesFile aFile,
                                         const char* aKey,
-                                        const PRUnichar **aParams,
+                                        const PRUnichar** aParams,
                                         PRUint32 aParamsLength,
                                         nsXPIDLString& aResult);
+  
+public:
+  template<PRUint32 N>
+  static nsresult FormatLocalizedString(PropertiesFile aFile,
+                                        const char* aKey,
+                                        const PRUnichar* (&aParams)[N],
+                                        nsXPIDLString& aResult)
+  {
+    return FormatLocalizedString(aFile, aKey, aParams, N, aResult);
+  }
 
   /**
    * Returns true if aDocument is a chrome document
    */
   static bool IsChromeDoc(nsIDocument *aDocument);
 
   /**
    * Returns true if aDocument is in a docshell whose parent is the same type
--- a/content/base/src/nsGkAtoms.cpp
+++ b/content/base/src/nsGkAtoms.cpp
@@ -60,11 +60,11 @@ using namespace mozilla;
 static const nsStaticAtom GkAtoms_info[] = {
 #define GK_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &nsGkAtoms::name_),
 #include "nsGkAtomList.h"
 #undef GK_ATOM
 };
 
 void nsGkAtoms::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(GkAtoms_info, ArrayLength(GkAtoms_info));
+  NS_RegisterStaticAtoms(GkAtoms_info);
 }
 
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -264,17 +264,16 @@ HandleMailtoSubject(nsCString& aPath) {
     if (NS_FAILED(rv))
       return;
     const PRUnichar *formatStrings[] = { brandName.get() };
     nsXPIDLString subjectStr;
     rv = nsContentUtils::FormatLocalizedString(
                                            nsContentUtils::eFORMS_PROPERTIES,
                                            "DefaultFormSubject",
                                            formatStrings,
-                                           ArrayLength(formatStrings),
                                            subjectStr);
     if (NS_FAILED(rv))
       return;
     aPath.AppendLiteral("subject=");
     nsCString subjectStrEscaped;
     aPath.Append(NS_EscapeURL(NS_ConvertUTF16toUTF8(subjectStr), esc_Query,
                               subjectStrEscaped));
   }
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -3825,17 +3825,17 @@ nsHTMLInputElement::GetValidationMessage
       GetTextLength(&textLength);
 
       strMaxLength.AppendInt(maxLength);
       strTextLength.AppendInt(textLength);
 
       const PRUnichar* params[] = { strMaxLength.get(), strTextLength.get() };
       rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                  "FormValidationTextTooLong",
-                                                 params, 2, message);
+                                                 params, message);
       aValidationMessage = message;
       break;
     }
     case VALIDITY_STATE_VALUE_MISSING:
     {
       nsXPIDLString message;
       nsCAutoString key;
       switch (mType)
@@ -3884,17 +3884,17 @@ nsHTMLInputElement::GetValidationMessage
                                                 message);
       } else {
         if (title.Length() > nsIConstraintValidation::sContentSpecifiedMaxLengthMessage) {
           title.Truncate(nsIConstraintValidation::sContentSpecifiedMaxLengthMessage);
         }
         const PRUnichar* params[] = { title.get() };
         rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                    "FormValidationPatternMismatchWithTitle",
-                                                   params, 1, message);
+                                                   params, message);
       }
       aValidationMessage = message;
       break;
     }
     default:
       rv = nsIConstraintValidation::GetValidationMessage(aValidationMessage, aType);
   }
 
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -1418,17 +1418,17 @@ nsHTMLTextAreaElement::GetValidationMess
         GetTextLength(&textLength);
 
         strMaxLength.AppendInt(maxLength);
         strTextLength.AppendInt(textLength);
 
         const PRUnichar* params[] = { strMaxLength.get(), strTextLength.get() };
         rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                    "FormValidationTextTooLong",
-                                                   params, 2, message);
+                                                   params, message);
         aValidationMessage = message;
       }
       break;
     case VALIDITY_STATE_VALUE_MISSING:
       {
         nsXPIDLString message;
         rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                 "FormValidationValueMissing",
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4697,17 +4697,17 @@ nsGlobalWindow::MakeScriptDialogTitle(ns
               nsCAutoString prepath;
               fixedURI->GetPrePath(prepath);
 
               NS_ConvertUTF8toUTF16 ucsPrePath(prepath);
               const PRUnichar *formatStrings[] = { ucsPrePath.get() };
               nsXPIDLString tempString;
               nsContentUtils::FormatLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                                     "ScriptDlgHeading",
-                                                    formatStrings, ArrayLength(formatStrings),
+                                                    formatStrings,
                                                     tempString);
               aOutTitle = tempString;
             }
           }
         }
       }
     }
     else { // failed to get subject principal
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -810,17 +810,17 @@ nsJSContext::DOMOperationCallback(JSCont
   if (script) {
     const char *filename = ::JS_GetScriptFilename(cx, script);
     if (filename) {
       nsXPIDLString scriptLocation;
       NS_ConvertUTF8toUTF16 filenameUTF16(filename);
       const PRUnichar *formatParams[] = { filenameUTF16.get() };
       rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
                                                  "KillScriptLocation",
-                                                 formatParams, 1,
+                                                 formatParams,
                                                  scriptLocation);
 
       if (NS_SUCCEEDED(rv) && scriptLocation) {
         msg.AppendLiteral("\n\n");
         msg.Append(scriptLocation);
 
         JSStackFrame *fp, *iterator = nsnull;
         fp = ::JS_FrameIterator(cx, &iterator);
--- a/editor/libeditor/html/nsEditProperty.cpp
+++ b/editor/libeditor/html/nsEditProperty.cpp
@@ -80,10 +80,10 @@ nsEditProperty::RegisterAtoms()
 {
   // inline tags
   static const nsStaticAtom property_atoms[] = {
 #define EDITOR_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &name_),
 #include "nsEditPropertyAtomList.h"
 #undef EDITOR_ATOM
   };
   
-  NS_RegisterStaticAtoms(property_atoms, ArrayLength(property_atoms));
+  NS_RegisterStaticAtoms(property_atoms);
 }
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -129,17 +129,17 @@ void
 nsTextServicesDocument::RegisterAtoms()
 {
   static const nsStaticAtom ts_atoms[] = {
 #define TS_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &name_),
 #include "nsTSAtomList.h"
 #undef TS_ATOM
   };
 
-  NS_RegisterStaticAtoms(ts_atoms, ArrayLength(ts_atoms));
+  NS_RegisterStaticAtoms(ts_atoms);
 }
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTextServicesDocument)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTextServicesDocument)
 
 NS_INTERFACE_MAP_BEGIN(nsTextServicesDocument)
   NS_INTERFACE_MAP_ENTRY(nsITextServicesDocument)
   NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
--- a/gfx/thebes/gfxAtoms.cpp
+++ b/gfx/thebes/gfxAtoms.cpp
@@ -53,10 +53,10 @@ using namespace mozilla;
 static const nsStaticAtom atoms[] = {
 #define GFX_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &gfxAtoms::name_),
 #include "gfxAtomList.h"
 #undef GFX_ATOM
 };
 
 void gfxAtoms::RegisterAtoms()
 {
-    NS_RegisterStaticAtoms(atoms, ArrayLength(atoms));
+    NS_RegisterStaticAtoms(atoms);
 }
--- a/layout/inspector/src/inDOMView.cpp
+++ b/layout/inspector/src/inDOMView.cpp
@@ -137,17 +137,17 @@ inDOMView::~inDOMView()
 #define DOMVIEW_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &inDOMView::name_),
 #include "inDOMViewAtomList.h"
 #undef DOMVIEW_ATOM
 };
 
 /* static */ void
 inDOMView::InitAtoms()
 {
-  NS_RegisterStaticAtoms(Atoms_info, ArrayLength(Atoms_info));
+  NS_RegisterStaticAtoms(Atoms_info);
 }
 
 ////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_ISUPPORTS3(inDOMView,
                    inIDOMView,
                    nsITreeView,
--- a/layout/style/nsCSSAnonBoxes.cpp
+++ b/layout/style/nsCSSAnonBoxes.cpp
@@ -63,18 +63,17 @@ static const nsStaticAtom CSSAnonBoxes_i
 #define CSS_ANON_BOX(name_, value_) \
   NS_STATIC_ATOM(name_##_buffer, (nsIAtom**)&nsCSSAnonBoxes::name_),
 #include "nsCSSAnonBoxList.h"
 #undef CSS_ANON_BOX
 };
 
 void nsCSSAnonBoxes::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(CSSAnonBoxes_info,
-                         ArrayLength(CSSAnonBoxes_info));
+  NS_RegisterStaticAtoms(CSSAnonBoxes_info);
 }
 
 bool nsCSSAnonBoxes::IsAnonBox(nsIAtom *aAtom)
 {
   return nsAtomListUtils::IsMember(aAtom, CSSAnonBoxes_info,
                                    ArrayLength(CSSAnonBoxes_info));
 }
 
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -730,17 +730,17 @@ static void AppendRuleToSheet(css::Rule*
 }
 
 #ifdef CSS_REPORT_PARSE_ERRORS
 
 #define REPORT_UNEXPECTED(msg_) \
   mScanner.ReportUnexpected(#msg_)
 
 #define REPORT_UNEXPECTED_P(msg_, params_) \
-  mScanner.ReportUnexpectedParams(#msg_, params_, ArrayLength(params_))
+  mScanner.ReportUnexpectedParams(#msg_, params_)
 
 #define REPORT_UNEXPECTED_EOF(lf_) \
   mScanner.ReportUnexpectedEOF(#lf_)
 
 #define REPORT_UNEXPECTED_EOF_CHAR(ch_) \
   mScanner.ReportUnexpectedEOF(ch_)
 
 #define REPORT_UNEXPECTED_TOKEN(msg_) \
--- a/layout/style/nsCSSPseudoClasses.cpp
+++ b/layout/style/nsCSSPseudoClasses.cpp
@@ -61,18 +61,17 @@ static const nsStaticAtom CSSPseudoClass
 #define CSS_PSEUDO_CLASS(name_, value_) \
   NS_STATIC_ATOM(name_##_buffer, &sPseudoClass_##name_),
 #include "nsCSSPseudoClassList.h"
 #undef CSS_PSEUDO_CLASS
 };
 
 void nsCSSPseudoClasses::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(CSSPseudoClasses_info,
-                         ArrayLength(CSSPseudoClasses_info));
+  NS_RegisterStaticAtoms(CSSPseudoClasses_info);
 }
 
 bool
 nsCSSPseudoClasses::HasStringArg(Type aType)
 {
   return aType == ePseudoClass_lang ||
          aType == ePseudoClass_mozEmptyExceptChildrenWithLocalname ||
          aType == ePseudoClass_mozSystemMetric ||
--- a/layout/style/nsCSSPseudoElements.cpp
+++ b/layout/style/nsCSSPseudoElements.cpp
@@ -75,18 +75,17 @@ static const PRUint32 CSSPseudoElements_
 #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \
   flags_,
 #include "nsCSSPseudoElementList.h"
 #undef CSS_PSEUDO_ELEMENT
 };
 
 void nsCSSPseudoElements::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(CSSPseudoElements_info,
-                         ArrayLength(CSSPseudoElements_info));
+  NS_RegisterStaticAtoms(CSSPseudoElements_info);
 }
 
 bool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
 {
   return nsAtomListUtils::IsMember(aAtom, CSSPseudoElements_info,
                                    ArrayLength(CSSPseudoElements_info));
 }
 
--- a/layout/style/nsCSSScanner.cpp
+++ b/layout/style/nsCSSScanner.cpp
@@ -542,17 +542,17 @@ nsCSSScanner::ReportUnexpectedToken(nsCS
   
   nsAutoString tokenString;
   tok.AppendToString(tokenString);
 
   const PRUnichar *params[] = {
     tokenString.get()
   };
 
-  ReportUnexpectedParams(aMessage, params, ArrayLength(params));
+  ReportUnexpectedParams(aMessage, params);
 }
 
 // aParams's first entry must be null, and we'll fill in the token
 void
 nsCSSScanner::ReportUnexpectedTokenParams(nsCSSToken& tok,
                                           const char* aMessage,
                                           const PRUnichar **aParams,
                                           PRUint32 aParamsLength)
--- a/layout/style/nsCSSScanner.h
+++ b/layout/style/nsCSSScanner.h
@@ -155,19 +155,29 @@ class nsCSSScanner {
 
 #ifdef CSS_REPORT_PARSE_ERRORS
   void AddToError(const nsSubstring& aErrorText);
   void OutputError();
   void ClearError();
 
   // aMessage must take no parameters
   void ReportUnexpected(const char* aMessage);
+  
+private:
   void ReportUnexpectedParams(const char* aMessage,
-                              const PRUnichar **aParams,
+                              const PRUnichar** aParams,
                               PRUint32 aParamsLength);
+
+public:
+  template<PRUint32 N>                           
+  void ReportUnexpectedParams(const char* aMessage,
+                              const PRUnichar* (&aParams)[N])
+    {
+      return ReportUnexpectedParams(aMessage, aParams, N);
+    }
   // aLookingFor is a plain string, not a format string
   void ReportUnexpectedEOF(const char* aLookingFor);
   // aLookingFor is a single character
   void ReportUnexpectedEOF(PRUnichar aLookingFor);
   // aMessage must take 1 parameter (for the string representation of the
   // unexpected token)
   void ReportUnexpectedToken(nsCSSToken& tok, const char *aMessage);
   // aParams's first entry must be null, and we'll fill in the token
--- a/parser/html/nsHtml5Atoms.cpp
+++ b/parser/html/nsHtml5Atoms.cpp
@@ -61,10 +61,10 @@ using namespace mozilla;
 static const nsStaticAtom Html5Atoms_info[] = {
 #define HTML5_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &nsHtml5Atoms::name_),
 #include "nsHtml5AtomList.h"
 #undef HTML5_ATOM
 };
 
 void nsHtml5Atoms::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(Html5Atoms_info, ArrayLength(Html5Atoms_info));
+  NS_RegisterStaticAtoms(Html5Atoms_info);
 }
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -790,22 +790,22 @@ nsHtml5TreeOperation::Perform(nsHtml5Tre
                       true);
       }
 
       nsXPIDLString message;
       if (otherAtom) {
         const PRUnichar* params[] = { atom->GetUTF16String(),
                                       otherAtom->GetUTF16String() };
         rv = nsContentUtils::FormatLocalizedString(
-          nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 2, message);
+          nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
         NS_ENSURE_SUCCESS(rv, rv);
       } else if (atom) {
         const PRUnichar* params[] = { atom->GetUTF16String() };
         rv = nsContentUtils::FormatLocalizedString(
-          nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 1, message);
+          nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
         NS_ENSURE_SUCCESS(rv, rv);
       } else {
         rv = nsContentUtils::GetLocalizedString(
           nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, message);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       nsAutoString title;
--- a/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/parser/htmlparser/src/nsHTMLTags.cpp
@@ -369,17 +369,17 @@ nsHTMLTags::AddRefTable(void)
 #include "nsHTMLTagList.h"
   };
 #undef HTML_TAG
 #undef HTML_HTMLELEMENT_TAG
 #undef HTML_OTHER
 
   if (gTableRefCount++ == 0) {
     // Fill in our static atom pointers
-    NS_RegisterStaticAtoms(sTagAtoms_info, ArrayLength(sTagAtoms_info));
+    NS_RegisterStaticAtoms(sTagAtoms_info);
 
 
     NS_ASSERTION(!gTagTable && !gTagAtomTable, "pre existing hash!");
 
     gTagTable = PL_NewHashTable(64, HTMLTagsHashCodeUCPtr,
                                 HTMLTagsKeyCompareUCPtr, PL_CompareValues,
                                 nsnull, nsnull);
     NS_ENSURE_TRUE(gTagTable, NS_ERROR_OUT_OF_MEMORY);
--- a/rdf/base/src/nsRDFContentSink.cpp
+++ b/rdf/base/src/nsRDFContentSink.cpp
@@ -332,17 +332,17 @@ RDFContentSinkImpl::RDFContentSinkImpl()
                                           &kRDF_Seq);
             rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
                                           &kRDF_nextVal);
         }
 
 
         rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
 
-        NS_RegisterStaticAtoms(rdf_atoms, ArrayLength(rdf_atoms));
+        NS_RegisterStaticAtoms(rdf_atoms);
     }
 
     mNodeIDMap.Init();
 
 #ifdef PR_LOGGING
     if (! gLog)
         gLog = PR_NewLogModule("nsRDFContentSink");
 #endif
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -542,17 +542,17 @@ class CheckStaticAtomSizes
                        offsetof(nsStringBuffer, mStorageSize)) &&
                       (offsetof(nsFakeStringBuffer<1>, mStringData) ==
                        sizeof(nsStringBuffer)),
                       "mocked-up strings' representations should be compatible");
   }
 };
 
 nsresult
-NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
+RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
 {
   // this does three things:
   // 1) wraps each static atom in a wrapper, if necessary
   // 2) initializes the address pointed to by each mBits slot
   // 3) puts the atom into the static atom table as well
   
   if (!gStaticAtomTable && !gStaticAtomTableSealed) {
     gStaticAtomTable = new nsDataHashtable<nsStringHashKey, nsIAtom*>();
--- a/xpcom/ds/nsStaticAtom.h
+++ b/xpcom/ds/nsStaticAtom.h
@@ -71,13 +71,18 @@ struct nsStaticAtom {
  */
 template <PRUint32 size>
 struct nsFakeStringBuffer {
     PRInt32 mRefCnt;
     PRUint32 mSize;
     nsStaticAtomStringType mStringData[size];
 };
 
-// Register static atoms with the atom table
+// Register an array of static atoms with the atom table
+template<PRUint32 N>
 nsresult
-NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
+NS_RegisterStaticAtoms(const nsStaticAtom (&atoms)[N])
+{
+    extern nsresult RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
+    return RegisterStaticAtoms(atoms, N);
+}
 
 #endif
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -302,17 +302,17 @@ nsDirectoryService::RealInit()
     nsRefPtr<nsDirectoryService> self = new nsDirectoryService();
     if (!self)
         return NS_ERROR_OUT_OF_MEMORY;
 
     rv = NS_NewISupportsArray(getter_AddRefs(((nsDirectoryService*) self)->mProviders));
     if (NS_FAILED(rv))
         return rv;
 
-    NS_RegisterStaticAtoms(directory_atoms, ArrayLength(directory_atoms));
+    NS_RegisterStaticAtoms(directory_atoms);
     
     // Let the list hold the only reference to the provider.
     nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider;
     if (!defaultProvider)
         return NS_ERROR_OUT_OF_MEMORY;
     // AppendElement returns true for success.
     rv = ((nsDirectoryService*) self)->mProviders->AppendElement(defaultProvider) ? NS_OK : NS_ERROR_FAILURE;
     if (NS_FAILED(rv))
--- a/xpcom/tests/MoreTestingAtoms.cpp
+++ b/xpcom/tests/MoreTestingAtoms.cpp
@@ -54,11 +54,10 @@ static const nsStaticAtom MoreTestingAto
 
 #define MORE_TESTING_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &MoreTestingAtoms::name_),
 #include "MoreTestingAtomList.h"
 #undef MORE_TESTING_ATOM
 };
 
 void MoreTestingAtoms::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(MoreTestingAtoms_info, 
-                         mozilla::ArrayLength(MoreTestingAtoms_info));
+  NS_RegisterStaticAtoms(MoreTestingAtoms_info);
 }
--- a/xpcom/tests/TestAtoms.cpp
+++ b/xpcom/tests/TestAtoms.cpp
@@ -207,17 +207,17 @@ test_atomtable()
   nsCOMPtr<nsIAtom> thirdNonPerm = do_GetAtom(THIRD_ATOM_STR);
   
   if (isStaticAtom(thirdNonPerm))
     return false;
 
   if (!thirdNonPerm || NS_GetNumberOfAtoms() != count + 1)
     return false;
 
-  NS_RegisterStaticAtoms(sAtoms_info, ArrayLength(sAtoms_info));
+  NS_RegisterStaticAtoms(sAtoms_info);
 
   return sAtom1 &&
          sAtom1->Equals(NS_LITERAL_STRING(FIRST_ATOM_STR)) &&
          isStaticAtom(sAtom1) &&
          sAtom2 &&
          sAtom2->Equals(NS_LITERAL_STRING(SECOND_ATOM_STR)) &&
          isStaticAtom(sAtom2) &&
          sAtom3 &&
--- a/xpcom/tests/TestingAtoms.cpp
+++ b/xpcom/tests/TestingAtoms.cpp
@@ -53,10 +53,10 @@
 static const nsStaticAtom TestingAtoms_info[] = {
 #define TESTING_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &TestingAtoms::name_),
 #include "TestingAtomList.h"
 #undef TESTING_ATOM
 };
 
 void TestingAtoms::AddRefAtoms()
 {
-  NS_RegisterStaticAtoms(TestingAtoms_info, mozilla::ArrayLength(TestingAtoms_info));
+  NS_RegisterStaticAtoms(TestingAtoms_info);
 }