Bug 1439770, part 2 - Inline constant argument to InterfaceDescriptorAddTypes. r=njn
MozReview-Commit-ID: 4mCgB5NFife
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ b/xpcom/typelib/xpt/xpt_struct.cpp
@@ -166,37 +166,36 @@ DoInterfaceDirectoryEntry(XPTArena *aren
!DoInterfaceDescriptor(arena, cursor, &ide->interface_descriptor)) {
return false;
}
return true;
}
static bool
-InterfaceDescriptorAddTypes(XPTArena *arena, XPTInterfaceDescriptor *id,
- uint16_t num)
+InterfaceDescriptorAddType(XPTArena *arena, XPTInterfaceDescriptor *id)
{
XPTTypeDescriptor *old = id->additional_types;
XPTTypeDescriptor *new_;
size_t old_size = id->num_additional_types * sizeof(XPTTypeDescriptor);
- size_t new_size = (num * sizeof(XPTTypeDescriptor)) + old_size;
+ size_t new_size = old_size + sizeof(XPTTypeDescriptor);
/* XXX should grow in chunks to minimize alloc overhead */
new_ = static_cast<XPTTypeDescriptor*>(XPT_CALLOC8(arena, new_size));
if (!new_)
return false;
if (old) {
memcpy(new_, old, old_size);
}
id->additional_types = new_;
- if (num + uint16_t(id->num_additional_types) > UINT8_MAX)
+ if (id->num_additional_types == UINT8_MAX)
return false;
- id->num_additional_types += num;
+ id->num_additional_types += 1;
return true;
}
bool
DoInterfaceDescriptor(XPTArena *arena, NotNull<XPTCursor*> outer,
XPTInterfaceDescriptor **idp)
{
XPTInterfaceDescriptor *id;
@@ -383,17 +382,17 @@ DoTypeDescriptor(XPTArena *arena, NotNul
break;
case TD_ARRAY: {
// argnum2 appears in the on-disk format but it isn't used.
uint8_t argnum2 = 0;
if (!XPT_Do8(cursor, &td->u.array.argnum) ||
!XPT_Do8(cursor, &argnum2))
return false;
- if (!InterfaceDescriptorAddTypes(arena, id, 1))
+ if (!InterfaceDescriptorAddType(arena, id))
return false;
td->u.array.additional_type = id->num_additional_types - 1;
if (!DoTypeDescriptor(arena, cursor,
&id->additional_types[td->u.array.additional_type],
id))
return false;
break;