[lazy] Allow calling fini() multiple times

This commit is contained in:
Behdad Esfahbod 2018-08-12 13:16:40 -07:00
parent 918ad9f5d9
commit 1b6b481262
1 changed files with 8 additions and 1 deletions

View File

@ -626,7 +626,14 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
{
inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */
inline void init (void) { instance.set_relaxed (nullptr); }
inline void fini (void) { destroy (instance.get ()); }
inline void fini (void)
{
retry:
Stored *p = instance.get ();
if (unlikely (p && !this->instance.cmpexch (p, nullptr)))
goto retry;
destroy (p);
}
inline Stored * create (void) const
{