Bug 1442363, part 8 - Constify XPTMethodDescriptor::params. r=njn
authorAndrew McCreight <continuation@gmail.com>
Tue, 27 Feb 2018 15:54:17 -0800
changeset 462079 e702856c3ec6be61b33a1d5ff2f91b13033ced55
parent 462078 d65876d7d6150375cadb50db3ac33f8c817dc62b
child 462080 2abeedcce11452fa670fc04adccf9dfcea7c749e
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1442363
milestone60.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 1442363, part 8 - Constify XPTMethodDescriptor::params. r=njn MozReview-Commit-ID: 3PvMeJW2P50
xpcom/typelib/xpt/xpt_struct.cpp
xpcom/typelib/xpt/xpt_struct.h
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ b/xpcom/typelib/xpt/xpt_struct.cpp
@@ -348,28 +348,32 @@ DoMethodDescriptor(XPTArena *arena, NotN
 {
     int i;
 
     if (!XPT_Do8(cursor, &md->flags) ||
         !XPT_DoCString(arena, cursor, &md->name) ||
         !XPT_Do8(cursor, &md->num_args))
         return false;
 
+    XPTParamDescriptor* params = nullptr;
+
     if (md->num_args) {
         size_t n = md->num_args * sizeof(XPTParamDescriptor);
-        md->params = static_cast<XPTParamDescriptor*>(XPT_CALLOC8(arena, n));
-        if (!md->params)
+        params = static_cast<XPTParamDescriptor*>(XPT_CALLOC8(arena, n));
+        if (!params)
             return false;
     }
 
     for(i = 0; i < md->num_args; i++) {
-        if (!DoParamDescriptor(arena, cursor, &md->params[i], id))
+        if (!DoParamDescriptor(arena, cursor, &params[i], id))
             return false;
     }
 
+    md->params = params;
+
     // |result| appears in the on-disk format but it isn't used,
     // because a method is either notxpcom, in which case it can't be
     // called from script so the XPT information is irrelevant, or the
     // result type is nsresult.
     XPTParamDescriptor result;
     if (!DoParamDescriptor(arena, cursor, &result, id))
         return false;
 
--- a/xpcom/typelib/xpt/xpt_struct.h
+++ b/xpcom/typelib/xpt/xpt_struct.h
@@ -262,15 +262,15 @@ struct XPTParamDescriptor {
 };
 
 /*
  * A MethodDescriptor is a variable-size record used to describe a single
  * interface method.
  */
 struct XPTMethodDescriptor {
   const char* name;
-  XPTParamDescriptor* params;
+  const XPTParamDescriptor* params;
   //XPTParamDescriptor result; // Present on disk, omitted here.
   uint8_t flags;
   uint8_t num_args;
 };
 
 #endif /* xpt_struct_h */