[subset-input] Use shared_ptr for sets

This commit is contained in:
Behdad Esfahbod 2023-01-12 12:37:48 -07:00
parent ef005bc82a
commit 875f9f6f22
2 changed files with 15 additions and 16 deletions

View File

@ -46,7 +46,7 @@ hb_subset_input_create_or_fail (void)
return nullptr;
for (auto& set : input->sets_iter ())
set = hb_set_create ();
set = hb::shared_ptr<hb_set_t> (hb_set_create ());
if (input->in_error ())
{

View File

@ -33,7 +33,7 @@
#include "hb-subset.h"
#include "hb-map.hh"
#include "hb-set.hh"
#include "hb-cplusplus.hh"
#include "hb-font.hh"
struct hb_ot_name_record_ids_t
@ -82,11 +82,10 @@ HB_MARK_AS_FLAG_T (hb_subset_flags_t);
struct hb_subset_input_t
{
hb_subset_input_t () {}
~hb_subset_input_t ()
{
for (hb_set_t* set : sets_iter ())
hb_set_destroy (set);
#ifdef HB_EXPERIMENTAL_API
for (auto _ : name_table_overrides)
_.second.fini ();
@ -96,19 +95,19 @@ struct hb_subset_input_t
hb_object_header_t header;
struct sets_t {
hb_set_t *glyphs;
hb_set_t *unicodes;
hb_set_t *no_subset_tables;
hb_set_t *drop_tables;
hb_set_t *name_ids;
hb_set_t *name_languages;
hb_set_t *layout_features;
hb_set_t *layout_scripts;
hb::shared_ptr<hb_set_t> glyphs;
hb::shared_ptr<hb_set_t> unicodes;
hb::shared_ptr<hb_set_t> no_subset_tables;
hb::shared_ptr<hb_set_t> drop_tables;
hb::shared_ptr<hb_set_t> name_ids;
hb::shared_ptr<hb_set_t> name_languages;
hb::shared_ptr<hb_set_t> layout_features;
hb::shared_ptr<hb_set_t> layout_scripts;
};
union {
sets_t sets;
hb_set_t* set_ptrs[sizeof (sets_t) / sizeof (hb_set_t*)];
hb::shared_ptr<hb_set_t> set_ptrs[sizeof (sets_t) / sizeof (hb_set_t*)];
};
unsigned flags;
@ -127,9 +126,9 @@ struct hb_subset_input_t
return sizeof (set_ptrs) / sizeof (hb_set_t*);
}
inline hb_array_t<hb_set_t*> sets_iter ()
inline hb_array_t<hb::shared_ptr<hb_set_t>> sets_iter ()
{
return hb_array_t<hb_set_t*> (set_ptrs, num_sets ());
return hb_array (set_ptrs);
}
bool in_error () const