Mark more unsized array's as arrayZ

This commit is contained in:
Behdad Esfahbod 2018-05-08 16:56:11 -07:00
parent 091c17df5a
commit 63f57f4dab
15 changed files with 131 additions and 131 deletions

View File

@ -67,11 +67,11 @@ struct BinSearchArrayOf
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (unlikely (i >= header.nUnits)) return Null(Type); if (unlikely (i >= header.nUnits)) return Null(Type);
return StructAtOffset<Type> (bytes, i * header.unitSize); return StructAtOffset<Type> (bytesZ, i * header.unitSize);
} }
inline Type& operator [] (unsigned int i) inline Type& operator [] (unsigned int i)
{ {
return StructAtOffset<Type> (bytes, i * header.unitSize); return StructAtOffset<Type> (bytesZ, i * header.unitSize);
} }
inline unsigned int get_size (void) const inline unsigned int get_size (void) const
{ return header.static_size + header.nUnits * header.unitSize; } { return header.static_size + header.nUnits * header.unitSize; }
@ -88,7 +88,7 @@ struct BinSearchArrayOf
* pointed to do have a simple sanitize(), ie. they do not * pointed to do have a simple sanitize(), ie. they do not
* reference other structs via offsets. * reference other structs via offsets.
*/ */
(void) (false && StructAtOffset<Type> (bytes, 0).sanitize (c)); (void) (false && StructAtOffset<Type> (bytesZ, 0).sanitize (c));
return_trace (true); return_trace (true);
} }
@ -111,7 +111,7 @@ struct BinSearchArrayOf
while (min <= max) while (min <= max)
{ {
int mid = (min + max) / 2; int mid = (min + max) / 2;
const Type *p = (const Type *) (((const char *) bytes) + (mid * size)); const Type *p = (const Type *) (((const char *) bytesZ) + (mid * size));
int c = p->cmp (key); int c = p->cmp (key);
if (c < 0) if (c < 0)
max = mid - 1; max = mid - 1;
@ -129,14 +129,14 @@ struct BinSearchArrayOf
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (header.sanitize (c) && return_trace (header.sanitize (c) &&
Type::static_size >= header.unitSize && Type::static_size >= header.unitSize &&
c->check_array (bytes, header.unitSize, header.nUnits)); c->check_array (bytesZ, header.unitSize, header.nUnits));
} }
protected: protected:
BinSearchHeader header; BinSearchHeader header;
HBUINT8 bytes[VAR]; HBUINT8 bytesZ[VAR];
public: public:
DEFINE_SIZE_ARRAY (10, bytes); DEFINE_SIZE_ARRAY (10, bytesZ);
}; };

View File

@ -334,7 +334,7 @@ struct kerx
HBUINT16 version; HBUINT16 version;
HBUINT16 padding; HBUINT16 padding;
HBUINT32 nTables; HBUINT32 nTables;
/*KerxTable tables[VAR];*/ /*KerxTable tablesZ[VAR]; XXX ArrayOf??? */
/*SubtableGlyphCoverageArray coverage_array;*/ /*SubtableGlyphCoverageArray coverage_array;*/
public: public:
DEFINE_SIZE_STATIC (8); DEFINE_SIZE_STATIC (8);

View File

@ -689,7 +689,7 @@ struct morx
inline void apply (hb_aat_apply_context_t *c) const inline void apply (hb_aat_apply_context_t *c) const
{ {
c->set_lookup_index (0); c->set_lookup_index (0);
const Chain *chain = chains; const Chain *chain = chainsZ;
unsigned int count = chainCount; unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
@ -706,7 +706,7 @@ struct morx
!chainCount.sanitize (c)) !chainCount.sanitize (c))
return_trace (false); return_trace (false);
const Chain *chain = chains; const Chain *chain = chainsZ;
unsigned int count = chainCount; unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
@ -723,7 +723,7 @@ struct morx
* 1 for mort, 2 or 3 for morx. */ * 1 for mort, 2 or 3 for morx. */
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
* table. */ * table. */
Chain chains[VAR]; /* Chains. */ Chain chainsZ[VAR]; /* Chains. */
public: public:
DEFINE_SIZE_MIN (8); DEFINE_SIZE_MIN (8);

View File

@ -100,7 +100,7 @@ typedef struct OffsetTable
else else
*table_count = MIN<unsigned int> (*table_count, tables.len - start_offset); *table_count = MIN<unsigned int> (*table_count, tables.len - start_offset);
const TableRecord *sub_tables = tables.array + start_offset; const TableRecord *sub_tables = tables.arrayZ + start_offset;
unsigned int count = *table_count; unsigned int count = *table_count;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
table_tags[i] = sub_tables[i].tag; table_tags[i] = sub_tables[i].tag;
@ -148,7 +148,7 @@ typedef struct OffsetTable
/* Write OffsetTables, alloc for and write actual table blobs. */ /* Write OffsetTables, alloc for and write actual table blobs. */
for (unsigned int i = 0; i < table_count; i++) for (unsigned int i = 0; i < table_count; i++)
{ {
TableRecord &rec = tables.array[i]; TableRecord &rec = tables.arrayZ[i];
hb_blob_t *blob = blobs[i]; hb_blob_t *blob = blobs[i];
rec.tag.set (tags[i]); rec.tag.set (tags[i]);
rec.length.set (hb_blob_get_length (blob)); rec.length.set (hb_blob_get_length (blob));
@ -188,7 +188,7 @@ typedef struct OffsetTable
checksum.set_for_data (this, dir_end - (const char *) this); checksum.set_for_data (this, dir_end - (const char *) this);
for (unsigned int i = 0; i < table_count; i++) for (unsigned int i = 0; i < table_count; i++)
{ {
TableRecord &rec = tables.array[i]; TableRecord &rec = tables.arrayZ[i];
checksum.set (checksum + rec.checkSum); checksum.set (checksum + rec.checkSum);
} }

View File

@ -920,17 +920,17 @@ struct ArrayOf
count -= start_offset; count -= start_offset;
count = MIN (count, *pcount); count = MIN (count, *pcount);
*pcount = count; *pcount = count;
return array + start_offset; return arrayZ + start_offset;
} }
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (unlikely (i >= len)) return Null(Type); if (unlikely (i >= len)) return Null(Type);
return array[i]; return arrayZ[i];
} }
inline Type& operator [] (unsigned int i) inline Type& operator [] (unsigned int i)
{ {
return array[i]; return arrayZ[i];
} }
inline unsigned int get_size (void) const inline unsigned int get_size (void) const
{ return len.static_size + len * Type::static_size; } { return len.static_size + len * Type::static_size; }
@ -952,7 +952,7 @@ struct ArrayOf
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!serialize (c, items_len))) return_trace (false); if (unlikely (!serialize (c, items_len))) return_trace (false);
for (unsigned int i = 0; i < items_len; i++) for (unsigned int i = 0; i < items_len; i++)
array[i] = items[i]; arrayZ[i] = items[i];
items += items_len; items += items_len;
return_trace (true); return_trace (true);
} }
@ -969,7 +969,7 @@ struct ArrayOf
* pointed to do have a simple sanitize(), ie. they do not * pointed to do have a simple sanitize(), ie. they do not
* reference other structs via offsets. * reference other structs via offsets.
*/ */
(void) (false && array[0].sanitize (c)); (void) (false && arrayZ[0].sanitize (c));
return_trace (true); return_trace (true);
} }
@ -979,7 +979,7 @@ struct ArrayOf
if (unlikely (!sanitize_shallow (c))) return_trace (false); if (unlikely (!sanitize_shallow (c))) return_trace (false);
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (unlikely (!array[i].sanitize (c, base))) if (unlikely (!arrayZ[i].sanitize (c, base)))
return_trace (false); return_trace (false);
return_trace (true); return_trace (true);
} }
@ -990,7 +990,7 @@ struct ArrayOf
if (unlikely (!sanitize_shallow (c))) return_trace (false); if (unlikely (!sanitize_shallow (c))) return_trace (false);
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (unlikely (!array[i].sanitize (c, base, user_data))) if (unlikely (!arrayZ[i].sanitize (c, base, user_data)))
return_trace (false); return_trace (false);
return_trace (true); return_trace (true);
} }
@ -1000,28 +1000,28 @@ struct ArrayOf
{ {
unsigned int count = len; unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!this->array[i].cmp (x)) if (!this->arrayZ[i].cmp (x))
return i; return i;
return -1; return -1;
} }
inline void qsort (void) inline void qsort (void)
{ {
::qsort (array, len, sizeof (Type), Type::cmp); ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
} }
private: private:
inline bool sanitize_shallow (hb_sanitize_context_t *c) const inline bool sanitize_shallow (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (len.sanitize (c) && c->check_array (array, Type::static_size, len)); return_trace (len.sanitize (c) && c->check_array (arrayZ, Type::static_size, len));
} }
public: public:
LenType len; LenType len;
Type array[VAR]; Type arrayZ[VAR];
public: public:
DEFINE_SIZE_ARRAY (sizeof (LenType), array); DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ);
}; };
template <typename Type> struct LArrayOf : ArrayOf<Type, HBUINT32> {}; template <typename Type> struct LArrayOf : ArrayOf<Type, HBUINT32> {};
@ -1036,7 +1036,7 @@ struct OffsetListOf : OffsetArrayOf<Type>
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (unlikely (i >= this->len)) return Null(Type); if (unlikely (i >= this->len)) return Null(Type);
return this+this->array[i]; return this+this->arrayZ[i];
} }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
@ -1060,7 +1060,7 @@ struct HeadlessArrayOf
inline const Type& operator [] (unsigned int i) const inline const Type& operator [] (unsigned int i) const
{ {
if (unlikely (i >= len || !i)) return Null(Type); if (unlikely (i >= len || !i)) return Null(Type);
return array[i-1]; return arrayZ[i-1];
} }
inline unsigned int get_size (void) const inline unsigned int get_size (void) const
{ return len.static_size + (len ? len - 1 : 0) * Type::static_size; } { return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
@ -1075,7 +1075,7 @@ struct HeadlessArrayOf
if (unlikely (!items_len)) return_trace (true); if (unlikely (!items_len)) return_trace (true);
if (unlikely (!c->extend (*this))) return_trace (false); if (unlikely (!c->extend (*this))) return_trace (false);
for (unsigned int i = 0; i < items_len - 1; i++) for (unsigned int i = 0; i < items_len - 1; i++)
array[i] = items[i]; arrayZ[i] = items[i];
items += items_len - 1; items += items_len - 1;
return_trace (true); return_trace (true);
} }
@ -1092,7 +1092,7 @@ struct HeadlessArrayOf
* pointed to do have a simple sanitize(), ie. they do not * pointed to do have a simple sanitize(), ie. they do not
* reference other structs via offsets. * reference other structs via offsets.
*/ */
(void) (false && array[0].sanitize (c)); (void) (false && arrayZ[0].sanitize (c));
return_trace (true); return_trace (true);
} }
@ -1102,14 +1102,14 @@ struct HeadlessArrayOf
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
return_trace (len.sanitize (c) && return_trace (len.sanitize (c) &&
(!len || c->check_array (array, Type::static_size, len - 1))); (!len || c->check_array (arrayZ, Type::static_size, len - 1)));
} }
public: public:
LenType len; LenType len;
Type array[VAR]; Type arrayZ[VAR];
public: public:
DEFINE_SIZE_ARRAY (sizeof (LenType), array); DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ);
}; };
@ -1123,7 +1123,7 @@ struct SortedArrayOf : ArrayOf<Type, LenType>
inline int bsearch (const SearchType &x) const inline int bsearch (const SearchType &x) const
{ {
/* Hand-coded bsearch here since this is in the hot inner loop. */ /* Hand-coded bsearch here since this is in the hot inner loop. */
const Type *arr = this->array; const Type *arr = this->arrayZ;
int min = 0, max = (int) this->len - 1; int min = 0, max = (int) this->len - 1;
while (min <= max) while (min <= max)
{ {

View File

@ -450,7 +450,7 @@ struct CmapSubtableLongSegmented
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false); if (unlikely (!c->extend_min (*this))) return_trace (false);
Supplier<CmapSubtableLongGroup> supplier (group_data.array, group_data.len); Supplier<CmapSubtableLongGroup> supplier (group_data.arrayZ, group_data.len);
if (unlikely (!groups.serialize (c, supplier, group_data.len))) return_trace (false); if (unlikely (!groups.serialize (c, supplier, group_data.len))) return_trace (false);
return true; return true;
} }

View File

@ -357,8 +357,8 @@ struct CBLC
unsigned int count = sizeTables.len; unsigned int count = sizeTables.len;
for (uint32_t i = 0; i < count; ++i) for (uint32_t i = 0; i < count; ++i)
{ {
unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex; unsigned int startGlyphIndex = sizeTables.arrayZ[i].startGlyphIndex;
unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex; unsigned int endGlyphIndex = sizeTables.arrayZ[i].endGlyphIndex;
if (startGlyphIndex <= glyph && glyph <= endGlyphIndex) if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
{ {
*x_ppem = sizeTables[i].ppemX; *x_ppem = sizeTables[i].ppemX;
@ -489,21 +489,21 @@ struct CBDT
case 17: { case 17: {
const GlyphBitmapDataFormat17& glyphFormat17 = const GlyphBitmapDataFormat17& glyphFormat17 =
StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset); StructAtOffset<GlyphBitmapDataFormat17> (this->cbdt, image_offset);
callback ((const uint8_t *) &glyphFormat17.data.array, callback ((const uint8_t *) &glyphFormat17.data.arrayZ,
glyphFormat17.data.len, i, gid); glyphFormat17.data.len, i, gid);
} }
break; break;
case 18: { case 18: {
const GlyphBitmapDataFormat18& glyphFormat18 = const GlyphBitmapDataFormat18& glyphFormat18 =
StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset); StructAtOffset<GlyphBitmapDataFormat18> (this->cbdt, image_offset);
callback ((const uint8_t *) &glyphFormat18.data.array, callback ((const uint8_t *) &glyphFormat18.data.arrayZ,
glyphFormat18.data.len, i, gid); glyphFormat18.data.len, i, gid);
} }
break; break;
case 19: { case 19: {
const GlyphBitmapDataFormat19& glyphFormat19 = const GlyphBitmapDataFormat19& glyphFormat19 =
StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset); StructAtOffset<GlyphBitmapDataFormat19> (this->cbdt, image_offset);
callback ((const uint8_t *) &glyphFormat19.data.array, callback ((const uint8_t *) &glyphFormat19.data.arrayZ,
glyphFormat19.data.len, i, gid); glyphFormat19.data.len, i, gid);
} }
break; break;

View File

@ -723,7 +723,7 @@ struct CoverageFormat1
template <typename set_t> template <typename set_t>
inline bool add_coverage (set_t *glyphs) const { inline bool add_coverage (set_t *glyphs) const {
return glyphs->add_sorted_array (glyphArray.array, glyphArray.len); return glyphs->add_sorted_array (glyphArray.arrayZ, glyphArray.len);
} }
public: public:
@ -1337,13 +1337,13 @@ struct VarData
const HBINT16 *scursor = reinterpret_cast<const HBINT16 *> (row); const HBINT16 *scursor = reinterpret_cast<const HBINT16 *> (row);
for (; i < scount; i++) for (; i < scount; i++)
{ {
float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count); float scalar = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count);
delta += scalar * *scursor++; delta += scalar * *scursor++;
} }
const HBINT8 *bcursor = reinterpret_cast<const HBINT8 *> (scursor); const HBINT8 *bcursor = reinterpret_cast<const HBINT8 *> (scursor);
for (; i < count; i++) for (; i < count; i++)
{ {
float scalar = regions.evaluate (regionIndices.array[i], coords, coord_count); float scalar = regions.evaluate (regionIndices.arrayZ[i], coords, coord_count);
delta += scalar * *bcursor++; delta += scalar * *bcursor++;
} }
@ -1472,7 +1472,7 @@ struct ConditionSet
{ {
unsigned int count = conditions.len; unsigned int count = conditions.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
if (!(this+conditions.array[i]).evaluate (coords, coord_len)) if (!(this+conditions.arrayZ[i]).evaluate (coords, coord_len))
return false; return false;
return true; return true;
} }
@ -1513,7 +1513,7 @@ struct FeatureTableSubstitution
unsigned int count = substitutions.len; unsigned int count = substitutions.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
const FeatureTableSubstitutionRecord &record = substitutions.array[i]; const FeatureTableSubstitutionRecord &record = substitutions.arrayZ[i];
if (record.featureIndex == feature_index) if (record.featureIndex == feature_index)
return &(this+record.feature); return &(this+record.feature);
} }
@ -1566,7 +1566,7 @@ struct FeatureVariations
unsigned int count = varRecords.len; unsigned int count = varRecords.len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
const FeatureVariationRecord &record = varRecords.array[i]; const FeatureVariationRecord &record = varRecords.arrayZ[i];
if ((this+record.conditions).evaluate (coords, coord_len)) if ((this+record.conditions).evaluate (coords, coord_len))
{ {
*index = i; *index = i;

View File

@ -269,7 +269,7 @@ struct Sequence
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this); TRACE_COLLECT_GLYPHS (this);
c->output->add_array (substitute.array, substitute.len); c->output->add_array (substitute.arrayZ, substitute.len);
} }
inline bool apply (hb_ot_apply_context_t *c) const inline bool apply (hb_ot_apply_context_t *c) const
@ -281,7 +281,7 @@ struct Sequence
* as a "multiplied" substitution. */ * as a "multiplied" substitution. */
if (unlikely (count == 1)) if (unlikely (count == 1))
{ {
c->replace_glyph (substitute.array[0]); c->replace_glyph (substitute.arrayZ[0]);
return_trace (true); return_trace (true);
} }
/* Spec disallows this, but Uniscribe allows it. /* Spec disallows this, but Uniscribe allows it.
@ -297,7 +297,7 @@ struct Sequence
for (unsigned int i = 0; i < count; i++) { for (unsigned int i = 0; i < count; i++) {
_hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i); _hb_glyph_info_set_lig_props_for_component (&c->buffer->cur(), i);
c->output_glyph_for_component (substitute.array[i], klass); c->output_glyph_for_component (substitute.arrayZ[i], klass);
} }
c->buffer->skip_glyph (); c->buffer->skip_glyph ();
@ -480,7 +480,7 @@ struct AlternateSubstFormat1
if (unlikely (iter.get_coverage () >= count)) if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()]; const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
c->output->add_array (alt_set.array, alt_set.len); c->output->add_array (alt_set.arrayZ, alt_set.len);
} }
} }
@ -611,7 +611,7 @@ struct Ligature
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{ {
TRACE_COLLECT_GLYPHS (this); TRACE_COLLECT_GLYPHS (this);
c->input->add_array (component.array, component.len ? component.len - 1 : 0); c->input->add_array (component.arrayZ, component.len ? component.len - 1 : 0);
c->output->add (ligGlyph); c->output->add (ligGlyph);
} }
@ -979,7 +979,7 @@ struct ReverseChainSingleSubstFormat1
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead); const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
count = substitute.len; count = substitute.len;
c->output->add_array (substitute.array, substitute.len); c->output->add_array (substitute.arrayZ, substitute.len);
} }
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
@ -1007,11 +1007,11 @@ struct ReverseChainSingleSubstFormat1
unsigned int start_index = 0, end_index = 0; unsigned int start_index = 0, end_index = 0;
if (match_backtrack (c, if (match_backtrack (c,
backtrack.len, (HBUINT16 *) backtrack.array, backtrack.len, (HBUINT16 *) backtrack.arrayZ,
match_coverage, this, match_coverage, this,
&start_index) && &start_index) &&
match_lookahead (c, match_lookahead (c,
lookahead.len, (HBUINT16 *) lookahead.array, lookahead.len, (HBUINT16 *) lookahead.arrayZ,
match_coverage, this, match_coverage, this,
1, &end_index)) 1, &end_index))
{ {

View File

@ -1713,10 +1713,10 @@ struct ChainRule
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
chain_context_closure_lookup (c, chain_context_closure_lookup (c,
backtrack.len, backtrack.array, backtrack.len, backtrack.arrayZ,
input.len, input.array, input.len, input.arrayZ,
lookahead.len, lookahead.array, lookahead.len, lookahead.arrayZ,
lookup.len, lookup.array, lookup.len, lookup.arrayZ,
lookup_context); lookup_context);
} }
@ -1727,10 +1727,10 @@ struct ChainRule
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
chain_context_collect_glyphs_lookup (c, chain_context_collect_glyphs_lookup (c,
backtrack.len, backtrack.array, backtrack.len, backtrack.arrayZ,
input.len, input.array, input.len, input.arrayZ,
lookahead.len, lookahead.array, lookahead.len, lookahead.arrayZ,
lookup.len, lookup.array, lookup.len, lookup.arrayZ,
lookup_context); lookup_context);
} }
@ -1741,10 +1741,10 @@ struct ChainRule
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return_trace (chain_context_would_apply_lookup (c, return_trace (chain_context_would_apply_lookup (c,
backtrack.len, backtrack.array, backtrack.len, backtrack.arrayZ,
input.len, input.array, input.len, input.arrayZ,
lookahead.len, lookahead.array, lookup.len, lookahead.len, lookahead.arrayZ, lookup.len,
lookup.array, lookup_context)); lookup.arrayZ, lookup_context));
} }
inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const inline bool apply (hb_ot_apply_context_t *c, ChainContextApplyLookupContext &lookup_context) const
@ -1754,10 +1754,10 @@ struct ChainRule
const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input); const ArrayOf<HBUINT16> &lookahead = StructAfter<ArrayOf<HBUINT16> > (input);
const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead); const ArrayOf<LookupRecord> &lookup = StructAfter<ArrayOf<LookupRecord> > (lookahead);
return_trace (chain_context_apply_lookup (c, return_trace (chain_context_apply_lookup (c,
backtrack.len, backtrack.array, backtrack.len, backtrack.arrayZ,
input.len, input.array, input.len, input.arrayZ,
lookahead.len, lookahead.array, lookup.len, lookahead.len, lookahead.arrayZ, lookup.len,
lookup.array, lookup_context)); lookup.arrayZ, lookup_context));
} }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
@ -2072,10 +2072,10 @@ struct ChainContextFormat3
{this, this, this} {this, this, this}
}; };
chain_context_closure_lookup (c, chain_context_closure_lookup (c,
backtrack.len, (const HBUINT16 *) backtrack.array, backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
input.len, (const HBUINT16 *) input.array + 1, input.len, (const HBUINT16 *) input.arrayZ + 1,
lookahead.len, (const HBUINT16 *) lookahead.array, lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
lookup.len, lookup.array, lookup.len, lookup.arrayZ,
lookup_context); lookup_context);
} }
@ -2093,10 +2093,10 @@ struct ChainContextFormat3
{this, this, this} {this, this, this}
}; };
chain_context_collect_glyphs_lookup (c, chain_context_collect_glyphs_lookup (c,
backtrack.len, (const HBUINT16 *) backtrack.array, backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
input.len, (const HBUINT16 *) input.array + 1, input.len, (const HBUINT16 *) input.arrayZ + 1,
lookahead.len, (const HBUINT16 *) lookahead.array, lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
lookup.len, lookup.array, lookup.len, lookup.arrayZ,
lookup_context); lookup_context);
} }
@ -2112,10 +2112,10 @@ struct ChainContextFormat3
{this, this, this} {this, this, this}
}; };
return_trace (chain_context_would_apply_lookup (c, return_trace (chain_context_would_apply_lookup (c,
backtrack.len, (const HBUINT16 *) backtrack.array, backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
input.len, (const HBUINT16 *) input.array + 1, input.len, (const HBUINT16 *) input.arrayZ + 1,
lookahead.len, (const HBUINT16 *) lookahead.array, lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
lookup.len, lookup.array, lookup_context)); lookup.len, lookup.arrayZ, lookup_context));
} }
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
@ -2139,10 +2139,10 @@ struct ChainContextFormat3
{this, this, this} {this, this, this}
}; };
return_trace (chain_context_apply_lookup (c, return_trace (chain_context_apply_lookup (c,
backtrack.len, (const HBUINT16 *) backtrack.array, backtrack.len, (const HBUINT16 *) backtrack.arrayZ,
input.len, (const HBUINT16 *) input.array + 1, input.len, (const HBUINT16 *) input.arrayZ + 1,
lookahead.len, (const HBUINT16 *) lookahead.array, lookahead.len, (const HBUINT16 *) lookahead.arrayZ,
lookup.len, lookup.array, lookup_context)); lookup.len, lookup.arrayZ, lookup_context));
} }
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const

View File

@ -238,14 +238,14 @@ struct post
if (version != 0x00020000 || glyph >= glyphNameIndex->len) if (version != 0x00020000 || glyph >= glyphNameIndex->len)
return hb_bytes_t (); return hb_bytes_t ();
unsigned int index = glyphNameIndex->array[glyph]; unsigned int index = glyphNameIndex->arrayZ[glyph];
if (index < NUM_FORMAT1_NAMES) if (index < NUM_FORMAT1_NAMES)
return format1_names (index); return format1_names (index);
index -= NUM_FORMAT1_NAMES; index -= NUM_FORMAT1_NAMES;
if (index >= index_to_offset.len) if (index >= index_to_offset.len)
return hb_bytes_t (); return hb_bytes_t ();
unsigned int offset = index_to_offset.array[index]; unsigned int offset = index_to_offset.arrayZ[index];
const uint8_t *data = pool + offset; const uint8_t *data = pool + offset;
unsigned int name_length = *data; unsigned int name_length = *data;

View File

@ -70,30 +70,30 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
if (!len) if (!len)
return value; return value;
else /* len == 1*/ else /* len == 1*/
return value - array[0].fromCoord + array[0].toCoord; return value - arrayZ[0].fromCoord + arrayZ[0].toCoord;
} }
if (value <= array[0].fromCoord) if (value <= arrayZ[0].fromCoord)
return value - array[0].fromCoord + array[0].toCoord; return value - arrayZ[0].fromCoord + arrayZ[0].toCoord;
unsigned int i; unsigned int i;
unsigned int count = len; unsigned int count = len;
for (i = 1; i < count && value > array[i].fromCoord; i++) for (i = 1; i < count && value > arrayZ[i].fromCoord; i++)
; ;
if (value >= array[i].fromCoord) if (value >= arrayZ[i].fromCoord)
return value - array[i].fromCoord + array[i].toCoord; return value - arrayZ[i].fromCoord + arrayZ[i].toCoord;
if (unlikely (array[i-1].fromCoord == array[i].fromCoord)) if (unlikely (arrayZ[i-1].fromCoord == arrayZ[i].fromCoord))
return array[i-1].toCoord; return arrayZ[i-1].toCoord;
int denom = array[i].fromCoord - array[i-1].fromCoord; int denom = arrayZ[i].fromCoord - arrayZ[i-1].fromCoord;
return array[i-1].toCoord + return arrayZ[i-1].toCoord +
((array[i].toCoord - array[i-1].toCoord) * ((arrayZ[i].toCoord - arrayZ[i-1].toCoord) *
(value - array[i-1].fromCoord) + denom/2) / denom; (value - arrayZ[i-1].fromCoord) + denom/2) / denom;
} }
DEFINE_SIZE_ARRAY (2, array); DEFINE_SIZE_ARRAY (2, arrayZ);
}; };
struct avar struct avar

View File

@ -531,25 +531,25 @@ struct hb_vector_t
{ {
unsigned int len; unsigned int len;
unsigned int allocated; unsigned int allocated;
Type *array; Type *arrayZ;
Type static_array[StaticSize]; Type static_array[StaticSize];
void init (void) void init (void)
{ {
len = 0; len = 0;
allocated = ARRAY_LENGTH (static_array); allocated = ARRAY_LENGTH (static_array);
array = static_array; arrayZ = static_array;
} }
inline Type& operator [] (unsigned int i) { return array[i]; } inline Type& operator [] (unsigned int i) { return arrayZ[i]; }
inline const Type& operator [] (unsigned int i) const { return array[i]; } inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; }
inline Type *push (void) inline Type *push (void)
{ {
if (unlikely (!resize (len + 1))) if (unlikely (!resize (len + 1)))
return nullptr; return nullptr;
return &array[len - 1]; return &arrayZ[len - 1];
} }
/* Allocate for size but don't adjust len. */ /* Allocate for size but don't adjust len. */
@ -566,21 +566,21 @@ struct hb_vector_t
Type *new_array = nullptr; Type *new_array = nullptr;
if (array == static_array) { if (arrayZ == static_array) {
new_array = (Type *) calloc (new_allocated, sizeof (Type)); new_array = (Type *) calloc (new_allocated, sizeof (Type));
if (new_array) if (new_array)
memcpy (new_array, array, len * sizeof (Type)); memcpy (new_array, arrayZ, len * sizeof (Type));
} else { } else {
bool overflows = (new_allocated < allocated) || _hb_unsigned_int_mul_overflows (new_allocated, sizeof (Type)); bool overflows = (new_allocated < allocated) || _hb_unsigned_int_mul_overflows (new_allocated, sizeof (Type));
if (likely (!overflows)) { if (likely (!overflows)) {
new_array = (Type *) realloc (array, new_allocated * sizeof (Type)); new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type));
} }
} }
if (unlikely (!new_array)) if (unlikely (!new_array))
return false; return false;
array = new_array; arrayZ = new_array;
allocated = new_allocated; allocated = new_allocated;
return true; return true;
@ -604,8 +604,8 @@ struct hb_vector_t
{ {
if (unlikely (i >= len)) if (unlikely (i >= len))
return; return;
memmove (static_cast<void *> (&array[i]), memmove (static_cast<void *> (&arrayZ[i]),
static_cast<void *> (&array[i + 1]), static_cast<void *> (&arrayZ[i + 1]),
(len - i - 1) * sizeof (Type)); (len - i - 1) * sizeof (Type));
len--; len--;
} }
@ -619,39 +619,39 @@ struct hb_vector_t
template <typename T> template <typename T>
inline Type *find (T v) { inline Type *find (T v) {
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
if (array[i] == v) if (arrayZ[i] == v)
return &array[i]; return &arrayZ[i];
return nullptr; return nullptr;
} }
template <typename T> template <typename T>
inline const Type *find (T v) const { inline const Type *find (T v) const {
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
if (array[i] == v) if (arrayZ[i] == v)
return &array[i]; return &arrayZ[i];
return nullptr; return nullptr;
} }
inline void qsort (int (*cmp)(const void*, const void*)) inline void qsort (int (*cmp)(const void*, const void*))
{ {
::qsort (array, len, sizeof (Type), cmp); ::qsort (arrayZ, len, sizeof (Type), cmp);
} }
inline void qsort (void) inline void qsort (void)
{ {
::qsort (array, len, sizeof (Type), Type::cmp); ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
} }
inline void qsort (unsigned int start, unsigned int end) inline void qsort (unsigned int start, unsigned int end)
{ {
::qsort (array + start, end - start, sizeof (Type), Type::cmp); ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp);
} }
template <typename T> template <typename T>
inline Type *lsearch (const T &x) inline Type *lsearch (const T &x)
{ {
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)
if (0 == this->array[i].cmp (&x)) if (0 == this->arrayZ[i].cmp (&x))
return &array[i]; return &arrayZ[i];
return nullptr; return nullptr;
} }
@ -659,13 +659,13 @@ struct hb_vector_t
inline Type *bsearch (const T &x) inline Type *bsearch (const T &x)
{ {
unsigned int i; unsigned int i;
return bfind (x, &i) ? &array[i] : nullptr; return bfind (x, &i) ? &arrayZ[i] : nullptr;
} }
template <typename T> template <typename T>
inline const Type *bsearch (const T &x) const inline const Type *bsearch (const T &x) const
{ {
unsigned int i; unsigned int i;
return bfind (x, &i) ? &array[i] : nullptr; return bfind (x, &i) ? &arrayZ[i] : nullptr;
} }
template <typename T> template <typename T>
inline bool bfind (const T &x, unsigned int *i) const inline bool bfind (const T &x, unsigned int *i) const
@ -674,7 +674,7 @@ struct hb_vector_t
while (min <= max) while (min <= max)
{ {
int mid = (min + max) / 2; int mid = (min + max) / 2;
int c = this->array[mid].cmp (&x); int c = this->arrayZ[mid].cmp (&x);
if (c < 0) if (c < 0)
max = mid - 1; max = mid - 1;
else if (c > 0) else if (c > 0)
@ -685,7 +685,7 @@ struct hb_vector_t
return true; return true;
} }
} }
if (max < 0 || (max < (int) this->len && this->array[max].cmp (&x) > 0)) if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0))
max++; max++;
*i = max; *i = max;
return false; return false;
@ -693,9 +693,9 @@ struct hb_vector_t
inline void fini (void) inline void fini (void)
{ {
if (array != static_array) if (arrayZ != static_array)
free (array); free (arrayZ);
array = nullptr; arrayZ = nullptr;
allocated = len = 0; allocated = len = 0;
} }
}; };

View File

@ -374,8 +374,8 @@ struct hb_set_t
if (!resize (count)) if (!resize (count))
return; return;
population = other->population; population = other->population;
memcpy (pages.array, other->pages.array, count * sizeof (pages.array[0])); memcpy (pages.arrayZ, other->pages.arrayZ, count * sizeof (pages.arrayZ[0]));
memcpy (page_map.array, other->page_map.array, count * sizeof (page_map.array[0])); memcpy (page_map.arrayZ, other->page_map.arrayZ, count * sizeof (page_map.arrayZ[0]));
} }
inline bool is_equal (const hb_set_t *other) const inline bool is_equal (const hb_set_t *other) const

View File

@ -157,7 +157,7 @@ _hb_subset_face_data_reference_blob (hb_subset_face_data_t *data)
unsigned int face_length = table_count * 16 + 12; unsigned int face_length = table_count * 16 + 12;
for (unsigned int i = 0; i < table_count; i++) for (unsigned int i = 0; i < table_count; i++)
face_length += _hb_ceil_to_4 (hb_blob_get_length (data->tables.array[i].blob)); face_length += _hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob));
char *buf = (char *) malloc (face_length); char *buf = (char *) malloc (face_length);
if (unlikely (!buf)) if (unlikely (!buf))