From e9407a2bd25f80d65559b6a869585033e2a08b24 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 2 Jun 2022 11:29:44 -0600 Subject: [PATCH] Use shared_ptr in one place See if valgrind is happy... --- src/hb-map.hh | 2 +- src/hb-ot-layout-gsubgpos.hh | 9 +++------ src/hb-ot-layout.cc | 10 ++-------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index 065ae1731..d3bb49a87 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -198,7 +198,7 @@ struct hb_hashmap_t return true; } - bool set (K key, const V& value) { return set_with_hash (key, hb_hash (key), value); } + bool set (K key, const V &value) { return set_with_hash (key, hb_hash (key), value); } bool set (K key, V&& value) { return set_with_hash (key, hb_hash (key), std::move (value)); } V get (K key) const diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index fff5974d8..048278500 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -111,12 +111,9 @@ struct hb_closure_context_t : if (!done_lookups_glyph_set->get (lookup_index)) { - hb_set_t* empty_set = hb_set_create (); + hb::shared_ptr empty_set {hb_set_create ()}; if (unlikely (!done_lookups_glyph_set->set (lookup_index, empty_set))) - { - hb_set_destroy (empty_set); return true; - } } hb_set_clear (done_lookups_glyph_set->get (lookup_index)); @@ -171,7 +168,7 @@ struct hb_closure_context_t : hb_closure_context_t (hb_face_t *face_, hb_set_t *glyphs_, hb_map_t *done_lookups_glyph_count_, - hb_hashmap_t *done_lookups_glyph_set_, + hb_hashmap_t> *done_lookups_glyph_set_, unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : face (face_), glyphs (glyphs_), @@ -195,7 +192,7 @@ struct hb_closure_context_t : private: hb_map_t *done_lookups_glyph_count; - hb_hashmap_t *done_lookups_glyph_set; + hb_hashmap_t> *done_lookups_glyph_set; unsigned int lookup_count = 0; }; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 9a8070a4a..f5031be81 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1501,15 +1501,12 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face, hb_set_t *glyphs /* OUT */) { hb_map_t done_lookups_glyph_count; - hb_hashmap_t done_lookups_glyph_set; + hb_hashmap_t> done_lookups_glyph_set; OT::hb_closure_context_t c (face, glyphs, &done_lookups_glyph_count, &done_lookups_glyph_set); const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); l.closure (&c, lookup_index); - - for (auto _ : done_lookups_glyph_set.iter ()) - hb_set_destroy (_.second); } /** @@ -1529,7 +1526,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face, hb_set_t *glyphs /* OUT */) { hb_map_t done_lookups_glyph_count; - hb_hashmap_t done_lookups_glyph_set; + hb_hashmap_t> done_lookups_glyph_set; OT::hb_closure_context_t c (face, glyphs, &done_lookups_glyph_count, &done_lookups_glyph_set); const GSUB& gsub = *face->table.GSUB->table; @@ -1551,9 +1548,6 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face, } } while (iteration_count++ <= HB_CLOSURE_MAX_STAGES && glyphs_length != glyphs->get_population ()); - - for (auto _ : done_lookups_glyph_set.iter ()) - hb_set_destroy (_.second); } /*