Bug 1438707, part 3 - De-macroize CURS_POINT. r=njn
MozReview-Commit-ID: CVBGPRVSF7s
--- a/xpcom/typelib/xpt/xpt_xdr.cpp
+++ b/xpcom/typelib/xpt/xpt_xdr.cpp
@@ -15,19 +15,21 @@
((cursor)->pool == XPT_HEADER \
? (cursor)->offset \
: (XPT_ASSERT((cursor)->state->data_offset), \
(cursor)->offset + (cursor)->state->data_offset))
#define CURS_POOL_OFFSET(cursor) \
(CURS_POOL_OFFSET_RAW(cursor) - 1)
-/* can be used as lvalue */
-#define CURS_POINT(cursor) \
- ((cursor)->state->pool_data[CURS_POOL_OFFSET(cursor)])
+static char*
+CursPoint(NotNull<XPTCursor*> cursor)
+{
+ return &cursor->state->pool_data[CURS_POOL_OFFSET(cursor)];
+}
static bool
CheckCount(NotNull<XPTCursor*> cursor, uint32_t space)
{
// Fail if we're in the data area and about to exceed the allocation.
// XXX Also fail if we're in the data area and !state->data_offset
if (cursor->pool == XPT_DATA &&
(CURS_POOL_OFFSET(cursor) + space > (cursor)->state->pool_allocated)) {
@@ -112,17 +114,17 @@ XPT_DoCString(XPTArena *arena, NotNull<X
*identp = NULL;
return true;
}
XPTCursor my_cursor;
my_cursor.pool = XPT_DATA;
my_cursor.offset = offset;
my_cursor.state = cursor->state;
- char* start = &CURS_POINT(&my_cursor);
+ char* start = CursPoint(WrapNotNull(&my_cursor));
char* end = strchr(start, 0); /* find the end of the string */
if (!end) {
fprintf(stderr, "didn't find end of string on decode!\n");
return false;
}
int len = end - start;
XPT_ASSERT(len > 0);
@@ -176,17 +178,17 @@ XPT_DoIID(NotNull<XPTCursor*> cursor, ns
#define XPT_DOINT(T, func, valuep) \
do { \
const size_t sz = sizeof(T); \
\
if (!CheckCount(cursor, sz)) { \
return false; \
} \
\
- *valuep = func(&CURS_POINT(cursor)); \
+ *valuep = func(CursPoint(cursor)); \
cursor->offset += sz; \
return true; \
} while(0)
bool
XPT_Do64(NotNull<XPTCursor*> cursor, int64_t *u64p)
{
XPT_DOINT(int64_t, mozilla::BigEndian::readInt64, u64p);
@@ -213,16 +215,16 @@ XPT_Do16(NotNull<XPTCursor*> cursor, uin
#undef XPT_DOINT
bool
XPT_Do8(NotNull<XPTCursor*> cursor, uint8_t *u8p)
{
if (!CheckCount(cursor, 1))
return false;
- *u8p = CURS_POINT(cursor);
+ *u8p = *CursPoint(cursor);
cursor->offset++;
return true;
}