bug 737412 - handle null sizeOfEntryExcludingThis pointer within ns{T,Base}Hashtable SizeOfExcludingThis functions. r=jfkthame
authorNicholas Nethercote <n.nethercote@gmail.com>
Fri, 23 Mar 2012 12:13:44 +0000
changeset 93460 18c70ab50559920a2ddfa7e42b934f785874de3b
parent 93459 1152d14294df24ac807730e4861075a5a81d8474
child 93461 dbd51616925a691de22fad8d350f41071b5f504c
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs737412
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 737412 - handle null sizeOfEntryExcludingThis pointer within ns{T,Base}Hashtable SizeOfExcludingThis functions. r=jfkthame
xpcom/glue/nsBaseHashtable.h
xpcom/glue/nsTHashtable.h
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -269,24 +269,25 @@ public:
    * @param     mallocSizeOf the function used to measure heap-allocated blocks
    * @param     userArg a pointer to pass to the
    *            <code>SizeOfEntryExcludingThisFun</code> function
    * @return    the summed size of all the entries
    */
   size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                              nsMallocSizeOfFun mallocSizeOf, void *userArg = nsnull)
   {
-    if (IsInitialized()) {
+    if (!IsInitialized()) {
+      return 0;
+    }
+    if (sizeOfEntryExcludingThis) {
       s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
-      return PL_DHashTableSizeOfExcludingThis(&this->mTable,
-                                              s_SizeOfStub,
-                                              mallocSizeOf,
-                                              &args);
+      return PL_DHashTableSizeOfExcludingThis(&this->mTable, s_SizeOfStub,
+                                              mallocSizeOf, &args);
     }
-    return 0;
+    return PL_DHashTableSizeOfExcludingThis(&this->mTable, NULL, mallocSizeOf);
   }
 
 protected:
   /**
    * used internally during EnumerateRead.  Allocated on the stack.
    * @param func the enumerator passed to EnumerateRead
    * @param userArg the userArg passed to EnumerateRead
    */
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -283,21 +283,24 @@ public:
    * @param     mallocSizeOf the function used to measure heap-allocated blocks
    * @param     userArg a pointer to pass to the
    *            <code>SizeOfEntryExcludingThisFun</code> function
    * @return    the summed size of all the entries
    */
   size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                              nsMallocSizeOfFun mallocSizeOf, void *userArg = NULL) const
   {
-    if (IsInitialized()) {
+    if (!IsInitialized()) {
+      return 0;
+    }
+    if (sizeOfEntryExcludingThis) {
       s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
       return PL_DHashTableSizeOfExcludingThis(&mTable, s_SizeOfStub, mallocSizeOf, &args);
     }
-    return 0;
+    return PL_DHashTableSizeOfExcludingThis(&mTable, NULL, mallocSizeOf);
   }
 
 #ifdef DEBUG
   /**
    * Mark the table as constant after initialization.
    *
    * This will prevent assertions when a read-only hash is accessed on multiple
    * threads without synchronization.