[set] Fix init/fini of set on the stack to call object init/fini

Part of https://github.com/harfbuzz/harfbuzz/issues/1017
This commit is contained in:
Behdad Esfahbod 2018-05-02 12:56:21 -04:00
parent 37b95612d4
commit f1f6bc0a6f
2 changed files with 14 additions and 4 deletions

View File

@ -193,18 +193,28 @@ struct hb_set_t
hb_vector_t<page_map_t, 8> page_map; hb_vector_t<page_map_t, 8> page_map;
hb_vector_t<page_t, 1> pages; hb_vector_t<page_t, 1> pages;
inline void init (void) inline void init_shallow (void)
{ {
in_error = false; in_error = false;
population = 0; population = 0;
page_map.init (); page_map.init ();
pages.init (); pages.init ();
} }
inline void fini (void) inline void init (void)
{
hb_object_init (this);
init_shallow ();
}
inline void fini_shallow (void)
{ {
page_map.fini (); page_map.fini ();
pages.fini (); pages.fini ();
} }
inline void fini (void)
{
hb_object_fini (this);
fini_shallow ();
}
inline bool resize (unsigned int count) inline bool resize (unsigned int count)
{ {

View File

@ -45,7 +45,7 @@ hb_set_create (void)
if (!(set = hb_object_create<hb_set_t> ())) if (!(set = hb_object_create<hb_set_t> ()))
return hb_set_get_empty (); return hb_set_get_empty ();
set->init (); set->init_shallow ();
return set; return set;
} }
@ -96,7 +96,7 @@ hb_set_destroy (hb_set_t *set)
{ {
if (!hb_object_destroy (set)) return; if (!hb_object_destroy (set)) return;
set->fini (); set->fini_shallow ();
free (set); free (set);
} }