Fix set initialization issues

This commit is contained in:
Behdad Esfahbod 2017-10-22 17:48:06 -04:00
parent 0ca915efc3
commit 8b9d9b71b0
4 changed files with 19 additions and 25 deletions

View File

@ -160,7 +160,7 @@ struct hb_collect_glyphs_context_t :
return HB_VOID;
/* Return if new lookup was recursed to before. */
if (recursed_lookups.has (lookup_index))
if (recursed_lookups->has (lookup_index))
return HB_VOID;
hb_set_t *old_before = before;
@ -176,7 +176,7 @@ struct hb_collect_glyphs_context_t :
input = old_input;
after = old_after;
recursed_lookups.add (lookup_index);
recursed_lookups->add (lookup_index);
return HB_VOID;
}
@ -187,7 +187,7 @@ struct hb_collect_glyphs_context_t :
hb_set_t *after;
hb_set_t *output;
recurse_func_t recurse_func;
hb_set_t recursed_lookups;
hb_set_t *recursed_lookups;
unsigned int nesting_level_left;
unsigned int debug_depth;
@ -203,15 +203,15 @@ struct hb_collect_glyphs_context_t :
after (glyphs_after ? glyphs_after : hb_set_get_empty ()),
output (glyphs_output ? glyphs_output : hb_set_get_empty ()),
recurse_func (nullptr),
recursed_lookups (),
recursed_lookups (nullptr),
nesting_level_left (nesting_level_left_),
debug_depth (0)
{
recursed_lookups.init ();
recursed_lookups = hb_set_create ();
}
~hb_collect_glyphs_context_t (void)
{
recursed_lookups.fini ();
hb_set_destroy (recursed_lookups);
}
void set_recurse_func (recurse_func_t func) { recurse_func = func; }

View File

@ -939,18 +939,19 @@ hb_ot_shape_glyphs_closure (hb_font_t *font,
for (unsigned int i = 0; i < count; i++)
add_char (font, buffer->unicode, mirror, info[i].codepoint, glyphs);
hb_set_t lookups;
lookups.init ();
hb_ot_shape_plan_collect_lookups (shape_plan, HB_OT_TAG_GSUB, &lookups);
hb_set_t *lookups = hb_set_create ();
hb_ot_shape_plan_collect_lookups (shape_plan, HB_OT_TAG_GSUB, lookups);
/* And find transitive closure. */
hb_set_t copy;
copy.init ();
hb_set_t *copy = hb_set_create ();
do {
copy.set (glyphs);
for (hb_codepoint_t lookup_index = -1; hb_set_next (&lookups, &lookup_index);)
copy->set (glyphs);
for (hb_codepoint_t lookup_index = -1; hb_set_next (lookups, &lookup_index);)
hb_ot_layout_lookup_substitute_closure (font->face, lookup_index, glyphs);
} while (!copy.is_equal (glyphs));
} while (!copy->is_equal (glyphs));
hb_set_destroy (copy);
hb_set_destroy (lookups);
hb_shape_plan_destroy (shape_plan);
}

View File

@ -175,15 +175,6 @@ struct hb_set_t
return true;
}
inline void init (void) {
hb_object_init (this);
page_map.init ();
pages.init ();
}
inline void fini (void) {
page_map.finish ();
pages.finish ();
}
inline void clear (void) {
if (unlikely (hb_object_is_inert (this)))
return;

View File

@ -45,7 +45,8 @@ hb_set_create (void)
if (!(set = hb_object_create<hb_set_t> ()))
return hb_set_get_empty ();
set->clear ();
set->page_map.init ();
set->pages.init ();
return set;
}
@ -95,7 +96,8 @@ hb_set_destroy (hb_set_t *set)
{
if (!hb_object_destroy (set)) return;
set->fini ();
set->page_map.finish ();
set->pages.finish ();
free (set);
}