From 37d61afd5eb2ce216eae032c6916ccbaad3ee31f Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 18 Aug 2022 21:05:48 +0000 Subject: [PATCH] [subset] add destructor to subset plan. This ensures that it's members get destructed before the plan itself is destructed, as hb_object_destroy calls the destructor for plan. --- src/hb-subset-plan.cc | 40 +-------------------------------------- src/hb-subset-plan.hh | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 7ff66333a..9123ba7be 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -620,7 +620,7 @@ _normalize_axes_location (hb_face_t *face, } if (has_avar) seg_maps = &StructAfter (*seg_maps); - + axis_count++; } all_axes_pinned = !axis_not_pinned; @@ -754,44 +754,6 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan) { if (!hb_object_destroy (plan)) return; - hb_set_destroy (plan->unicodes); - hb_set_destroy (plan->name_ids); - hb_set_destroy (plan->name_languages); - hb_set_destroy (plan->layout_features); - hb_set_destroy (plan->layout_scripts); - hb_set_destroy (plan->glyphs_requested); - hb_set_destroy (plan->drop_tables); - hb_set_destroy (plan->no_subset_tables); - hb_face_destroy (plan->source); - hb_face_destroy (plan->dest); - hb_map_destroy (plan->codepoint_to_glyph); - hb_map_destroy (plan->glyph_map); - hb_map_destroy (plan->reverse_glyph_map); - hb_map_destroy (plan->glyph_map_gsub); - hb_set_destroy (plan->_glyphset); - hb_set_destroy (plan->_glyphset_gsub); - hb_set_destroy (plan->_glyphset_mathed); - hb_set_destroy (plan->_glyphset_colred); - hb_map_destroy (plan->gsub_lookups); - hb_map_destroy (plan->gpos_lookups); - hb_map_destroy (plan->gsub_features); - hb_map_destroy (plan->gpos_features); - hb_map_destroy (plan->colrv1_layers); - hb_map_destroy (plan->colr_palettes); - hb_set_destroy (plan->layout_variation_indices); - hb_map_destroy (plan->layout_variation_idx_map); - - hb_hashmap_destroy (plan->gsub_langsys); - hb_hashmap_destroy (plan->gpos_langsys); - hb_hashmap_destroy (plan->axes_location); - hb_hashmap_destroy (plan->sanitized_table_cache); - - if (plan->user_axes_location) - { - hb_object_destroy (plan->user_axes_location); - hb_free (plan->user_axes_location); - } - hb_free (plan); } diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 8912ae70d..874d12540 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -37,6 +37,50 @@ struct hb_subset_plan_t { + hb_subset_plan_t () + {} + + ~hb_subset_plan_t() + { + hb_set_destroy (unicodes); + hb_set_destroy (name_ids); + hb_set_destroy (name_languages); + hb_set_destroy (layout_features); + hb_set_destroy (layout_scripts); + hb_set_destroy (glyphs_requested); + hb_set_destroy (drop_tables); + hb_set_destroy (no_subset_tables); + hb_face_destroy (source); + hb_face_destroy (dest); + hb_map_destroy (codepoint_to_glyph); + hb_map_destroy (glyph_map); + hb_map_destroy (reverse_glyph_map); + hb_map_destroy (glyph_map_gsub); + hb_set_destroy (_glyphset); + hb_set_destroy (_glyphset_gsub); + hb_set_destroy (_glyphset_mathed); + hb_set_destroy (_glyphset_colred); + hb_map_destroy (gsub_lookups); + hb_map_destroy (gpos_lookups); + hb_map_destroy (gsub_features); + hb_map_destroy (gpos_features); + hb_map_destroy (colrv1_layers); + hb_map_destroy (colr_palettes); + hb_set_destroy (layout_variation_indices); + hb_map_destroy (layout_variation_idx_map); + + hb_hashmap_destroy (gsub_langsys); + hb_hashmap_destroy (gpos_langsys); + hb_hashmap_destroy (axes_location); + hb_hashmap_destroy (sanitized_table_cache); + + if (user_axes_location) + { + hb_object_destroy (user_axes_location); + hb_free (user_axes_location); + } + } + hb_object_header_t header; bool successful;