diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 00ad434b5c5c7849999114ea7c44a03495e31dda..5b51fa7c2dd348e6cd0a18fb5be6528f6f9c2c8e 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -65,23 +65,23 @@ template inline Type* CastP(TObject *X) { return reinterpret_cast (X); } -/* StructAtOffset(X,Ofs) returns the struct T& that is placed at memory - * location of X plus Ofs bytes. */ -template -inline const Type& StructAtOffset(const TObject &X, unsigned int offset) -{ return * reinterpret_cast (CharP(&X) + offset); } -template -inline Type& StructAtOffset(TObject &X, unsigned int offset) -{ return * reinterpret_cast (CharP(&X) + offset); } +/* StructAtOffset(P,Ofs) returns the struct T& that is placed at memory + * location pointed to by P plus Ofs bytes. */ +template +inline const Type& StructAtOffset(const void *P, unsigned int offset) +{ return * reinterpret_cast (CharP(P) + offset); } +template +inline Type& StructAtOffset(void *P, unsigned int offset) +{ return * reinterpret_cast (CharP(P) + offset); } /* StructAfter(X) returns the struct T& that is placed after X. * Works with X of variable size also. X must implement get_size() */ template inline const Type& StructAfter(const TObject &X) -{ return StructAtOffset(X, X.get_size()); } +{ return StructAtOffset(&X, X.get_size()); } template inline Type& StructAfter(TObject &X) -{ return StructAtOffset(X, X.get_size()); } +{ return StructAtOffset(&X, X.get_size()); } @@ -472,7 +472,7 @@ struct GenericOffsetTo : OffsetType { unsigned int offset = *this; if (unlikely (!offset)) return Null(Type); - return StructAtOffset (*CharP(base), offset); + return StructAtOffset (base, offset); } inline bool sanitize (hb_sanitize_context_t *context, void *base) { @@ -480,7 +480,7 @@ struct GenericOffsetTo : OffsetType if (!context->check_struct (this)) return false; unsigned int offset = *this; if (unlikely (!offset)) return true; - Type &obj = StructAtOffset (*CharP(base), offset); + Type &obj = StructAtOffset (base, offset); return likely (obj.sanitize (context)) || neuter (context); } template @@ -489,7 +489,7 @@ struct GenericOffsetTo : OffsetType if (!context->check_struct (this)) return false; unsigned int offset = *this; if (unlikely (!offset)) return true; - Type &obj = StructAtOffset (*CharP(base), offset); + Type &obj = StructAtOffset (base, offset); return likely (obj.sanitize (context, user_data)) || neuter (context); } diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index a4381165d2dadbb33ccb6dfc6dfb6a3c122459d8..b18264d380fa51047ae1a277ea1672f09a8cc35a 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -618,7 +618,7 @@ struct PairPosFormat1 context->buffer->in_pos = j; return true; } - record = &StructAtOffset (*record, record_size); + record = &StructAtOffset (record, record_size); } return false; @@ -1409,7 +1409,7 @@ struct ExtensionPos : Extension { unsigned int offset = get_offset (); if (unlikely (!offset)) return Null(PosLookupSubTable); - return StructAtOffset (*this, offset); + return StructAtOffset (this, offset); } inline bool apply (hb_apply_context_t *context) const; @@ -1608,7 +1608,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *context) if (unlikely (!Extension::sanitize (context))) return false; unsigned int offset = get_offset (); if (unlikely (!offset)) return true; - return StructAtOffset (*this, offset).sanitize (context); + return StructAtOffset (this, offset).sanitize (context); } static inline bool position_lookup (hb_apply_context_t *context, unsigned int lookup_index) diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index ba933de346077e049135e7b417d38a9faabe6eb4..ccc51e74185d853ce84dae6e23b09090981e386a 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -586,7 +586,7 @@ struct ExtensionSubst : Extension { unsigned int offset = get_offset (); if (unlikely (!offset)) return Null(SubstLookupSubTable); - return StructAtOffset (*this, offset); + return StructAtOffset (this, offset); } inline bool apply (hb_apply_context_t *context) const; @@ -916,7 +916,7 @@ inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *context) if (unlikely (!Extension::sanitize (context))) return false; unsigned int offset = get_offset (); if (unlikely (!offset)) return true; - return StructAtOffset (*this, offset).sanitize (context); + return StructAtOffset (this, offset).sanitize (context); } inline bool ExtensionSubst::is_reverse (void) const