From bb9abb4efd7d72198ffe8abb137ccf07ae17743e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 11 Nov 2018 00:39:52 -0500 Subject: [PATCH] [hmtx/port] Use hb_blob_ptr_t --- src/hb-ot-hmtx-table.hh | 24 ++++++++++-------------- src/hb-ot-post-table.hh | 11 +++++------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index f898a03..7a1eb79 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -113,7 +113,7 @@ struct hmtxvmtx DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in src has %d advances, %d lsbs", HB_UNTAG(T::tableTag), _mtx.num_advances, _mtx.num_metrics - _mtx.num_advances); DEBUG_MSG(SUBSET, nullptr, "%c%c%c%c in dest has %d advances, %d lsbs, %u bytes", HB_UNTAG(T::tableTag), num_advances, gids.len - num_advances, (unsigned int) dest_sz); - const char *source_table = hb_blob_get_data (_mtx.blob, nullptr); + const char *source_table = hb_blob_get_data (_mtx.table.get_blob (), nullptr); // Copy everything over LongMetric * old_metrics = (LongMetric *) source_table; FWORD *lsbs = (FWORD *) (old_metrics + _mtx.num_advances); @@ -221,10 +221,10 @@ struct hmtxvmtx has_font_extents = got_font_extents; - blob = hb_sanitize_context_t().reference_table (face, T::tableTag); + table = hb_sanitize_context_t().reference_table (face, T::tableTag); /* Cap num_metrics() and num_advances() based on table length. */ - unsigned int len = hb_blob_get_length (blob); + unsigned int len = table.get_length (); if (unlikely (num_advances * 4 > len)) num_advances = len / 4; num_metrics = num_advances + (len - 4 * num_advances) / 2; @@ -234,19 +234,17 @@ struct hmtxvmtx if (unlikely (!num_advances)) { num_metrics = num_advances = 0; - hb_blob_destroy (blob); - blob = hb_blob_get_empty (); + hb_blob_destroy (table.get_blob ()); + table = hb_blob_get_empty (); } - table = blob->as (); - var_blob = hb_sanitize_context_t().reference_table (face, T::variationsTag); - var_table = var_blob->as (); + var_table = hb_sanitize_context_t().reference_table (face, T::variationsTag); } inline void fini (void) { - hb_blob_destroy (blob); - hb_blob_destroy (var_blob); + hb_blob_destroy (table.get_blob ()); + hb_blob_destroy (var_table.get_blob ()); } /* TODO Add variations version. */ @@ -301,10 +299,8 @@ struct hmtxvmtx unsigned int default_advance; private: - const hmtxvmtx *table; - hb_blob_t *blob; - const HVARVVAR *var_table; - hb_blob_t *var_blob; + hb_blob_ptr_t table; + hb_blob_ptr_t var_table; }; protected: diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 77eef3f..4850581 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -101,9 +101,8 @@ struct post { index_to_offset.init (); - blob = hb_sanitize_context_t().reference_table (face); - const post *table = blob->as (); - unsigned int table_length = blob->length; + table = hb_sanitize_context_t().reference_table (face); + unsigned int table_length = table.get_length (); version = table->version.to_int (); if (version != 0x00020000) @@ -114,7 +113,7 @@ struct post glyphNameIndex = &v2.glyphNameIndex; pool = &StructAfter (v2.glyphNameIndex); - const uint8_t *end = (uint8_t *) table + table_length; + const uint8_t *end = (const uint8_t *) (const void *) table + table_length; for (const uint8_t *data = pool; index_to_offset.len < 65535 && data < end && data + *data < end; data += 1 + *data) @@ -124,7 +123,7 @@ struct post { index_to_offset.fini (); free (gids_sorted_by_name.get ()); - hb_blob_destroy (blob); + hb_blob_destroy (table.get_blob ()); } inline bool get_glyph_name (hb_codepoint_t glyph, @@ -244,7 +243,7 @@ struct post } private: - hb_blob_t *blob; + hb_blob_ptr_t table; uint32_t version; const ArrayOf *glyphNameIndex; hb_vector_t index_to_offset; -- 2.7.4