Bug 1442363, part 1 - Constify RegisterXPTHeader(). r=njn

Once the XPT data is statically allocated, all of the pointers in
xpt_struct.h have to be made const, as well as the XPTHeader
itself. The existing consumers mostly assume things are const already,
so the bulk of the work is tweaking the deserialization code in
xpt_struct.cpp so that the final result is const. I've broken up these
changes into a set of patches.

This patch also gets rid of xptiTypelibGuts::GetHeader(), which is
never called.

MozReview-Commit-ID: FJpmNjY87SN

--HG--
extra : rebase_source : b28456625e4c80023bd350c67163085011bc7cee
This commit is contained in:
Andrew McCreight 2018-02-27 14:58:03 -08:00
Родитель a972280d60
Коммит b458c8cf4e
4 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -57,7 +57,7 @@ private:
void InitMemoryReporter();
void RegisterXPTHeader(XPTHeader* aHeader);
void RegisterXPTHeader(const XPTHeader* aHeader);
// idx is the index of this interface in the XPTHeader
void VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,

Просмотреть файл

@ -116,7 +116,7 @@ XPTInterfaceInfoManager::RegisterBuffer(char *buf, uint32_t length)
}
void
XPTInterfaceInfoManager::RegisterXPTHeader(XPTHeader* aHeader)
XPTInterfaceInfoManager::RegisterXPTHeader(const XPTHeader* aHeader)
{
if (aHeader->major_version >= XPT_MAJOR_INCOMPATIBLE_VERSION) {
NS_ASSERTION(!aHeader->num_interfaces,"bad libxpt");

Просмотреть файл

@ -20,7 +20,7 @@ CheckNoVTable<xptiTypelibGuts> gChecker;
// static
xptiTypelibGuts*
xptiTypelibGuts::Create(XPTHeader* aHeader)
xptiTypelibGuts::Create(const XPTHeader* aHeader)
{
NS_ASSERTION(aHeader, "bad param");
size_t n = sizeof(xptiTypelibGuts) +

Просмотреть файл

@ -91,9 +91,8 @@ extern XPTArena* gXPTIStructArena;
class xptiTypelibGuts
{
public:
static xptiTypelibGuts* Create(XPTHeader* aHeader);
static xptiTypelibGuts* Create(const XPTHeader* aHeader);
XPTHeader* GetHeader() {return mHeader;}
uint16_t GetEntryCount() const {return mHeader->num_interfaces;}
void SetEntryAt(uint16_t i, xptiInterfaceEntry* ptr)
@ -107,13 +106,13 @@ public:
const char* GetEntryNameAt(uint16_t i);
private:
explicit xptiTypelibGuts(XPTHeader* aHeader)
explicit xptiTypelibGuts(const XPTHeader* aHeader)
: mHeader(aHeader)
{ }
~xptiTypelibGuts();
private:
XPTHeader* mHeader; // hold pointer into arena
const XPTHeader* mHeader; // hold pointer into arena
xptiInterfaceEntry* mEntryArray[1]; // Always last. Sized to fit.
};