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 93531 220f36e7f9f78d656680e400b19f76c70af0eb48
parent 93530 1e64ae9b40096ba2d66ce34e1388f8da770129e6
child 93532 405657ee89b00dd2029b1f4828b18915dc0d6af3
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.