Add hb_addressof() and use it to fix bug after hb_bytes_t merge

We cannot take address hb_bytes_t direction.  We need to use the
newly added hb_addressof(), ala std::addressof().
This commit is contained in:
Behdad Esfahbod 2018-12-17 20:23:26 -05:00
parent 49334f9b50
commit 8d2d410256
2 changed files with 11 additions and 1 deletions

View File

@ -234,6 +234,15 @@ hb_ctz (T v)
* Tiny stuff.
*/
template <typename T>
T* hb_addressof (T& arg)
{
/* https://en.cppreference.com/w/cpp/memory/addressof */
return reinterpret_cast<T*>(
&const_cast<char&>(
reinterpret_cast<const volatile char&>(arg)));
}
/* ASCII tag/character handling */
static inline bool ISALPHA (unsigned char c)
{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); }

View File

@ -168,7 +168,8 @@ struct post
}
hb_bytes_t st (name, len);
const uint16_t *gid = (const uint16_t *) hb_bsearch_r (&st, gids, count, sizeof (gids[0]), cmp_key, (void *) this);
const uint16_t *gid = (const uint16_t *) hb_bsearch_r (hb_addressof (st), gids, count,
sizeof (gids[0]), cmp_key, (void *) this);
if (gid)
{
*glyph = *gid;