From 4a6a692e3ea4fab632a0162c6d513dc151054d8f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 19 Nov 2018 13:04:43 -0500 Subject: [PATCH] [fvar] Use hb_array_t for axes --- src/hb-dsalgs.hh | 6 ++++++ src/hb-ot-var-fvar-table.hh | 14 ++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 7a207f5d2..8e59fdee4 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -573,6 +573,10 @@ struct hb_array_t inline unsigned int get_size (void) const { return len * sizeof (Type); } + template + inline bool sanitize (hb_sanitize_context_t *c) const + { return c->check_array (arrayZ, len); } + template inline operator T * (void) const { return arrayZ; } inline Type * operator & (void) const { return arrayZ; } @@ -598,6 +602,8 @@ struct hb_array_t Type *arrayZ; unsigned int len; }; +template +hb_array_t hb_array (T *array, unsigned int len) { return hb_array_t (array, len); } struct HbOpOr diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 66618a5a1..b4fdd5fad 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -114,9 +114,6 @@ struct fvar inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const { - if (unlikely (index >= axisCount)) - return false; - if (info) { const AxisRecord &axis = get_axes ()[index]; @@ -133,9 +130,6 @@ struct fvar inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const { - if (unlikely (index >= axisCount)) - return (hb_ot_var_axis_flags_t) 0; - const AxisRecord &axis = get_axes ()[index]; return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags; } @@ -195,11 +189,11 @@ struct fvar } protected: - inline const AxisRecord * get_axes (void) const - { return &(this+firstAxis); } + inline hb_array_t get_axes (void) const + { return hb_array (&(this+firstAxis), axisCount); } - inline const InstanceRecord * get_instances (void) const - { return &StructAtOffset (get_axes () + axisCount, 0); } + inline const InstanceRecord * get_first_instance (void) const + { return &StructAfter (get_axes ()); } protected: FixedVersion<>version; /* Version of the fvar table