diff --git a/src/hb-subset-accelerator.hh b/src/hb-subset-accelerator.hh index 1caf93c7f..53fea0e77 100644 --- a/src/hb-subset-accelerator.hh +++ b/src/hb-subset-accelerator.hh @@ -60,6 +60,10 @@ struct hb_subset_accelerator_t if (!value) return; hb_subset_accelerator_t* accel = (hb_subset_accelerator_t*) value; + + if (accel->cff_accelerator && accel->destroy_cff_accelerator) + accel->destroy_cff_accelerator ((void*) accel->cff_accelerator); + accel->~hb_subset_accelerator_t (); hb_free (accel); } @@ -67,7 +71,7 @@ struct hb_subset_accelerator_t hb_subset_accelerator_t(const hb_map_t& unicode_to_gid_, const hb_set_t& unicodes_) : unicode_to_gid(unicode_to_gid_), unicodes(unicodes_), - has_seac(false), cff_accelerator(nullptr) {} + has_seac(false), cff_accelerator(nullptr), destroy_cff_accelerator(nullptr) {} // Generic const hb_map_t unicode_to_gid; @@ -76,6 +80,7 @@ struct hb_subset_accelerator_t // CFF bool has_seac; CFF::cff_subset_accelerator_t* cff_accelerator; + hb_destroy_func_t destroy_cff_accelerator; // TODO(garretrieger): cumulative glyf checksum map // TODO(garretrieger): sanitized table cache. diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 8b14c88b8..0286c7ff4 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -404,7 +404,7 @@ struct parsed_cs_str_vec_t : hb_vector_t struct cff_subset_accelerator_t { - static cff_subset_accelerator_t* create( + static cff_subset_accelerator_t* create ( hb_face_t* original_face, const parsed_cs_str_vec_t& parsed_charstrings, const parsed_cs_str_vec_t& parsed_global_subrs, @@ -418,7 +418,7 @@ struct cff_subset_accelerator_t return accel; } - static void destroy(void* value) { + static void destroy (void* value) { if (!value) return; cff_subset_accelerator_t* accel = (cff_subset_accelerator_t*) value; @@ -1025,6 +1025,8 @@ struct subr_subsetter_t parsed_charstrings, parsed_global_subrs, parsed_local_subrs); + plan->inprogress_accelerator->destroy_cff_accelerator = + cff_subset_accelerator_t::destroy; }