void hb_buffer_destroy(hb_buffer_t * buffer) { if (!buffer) return; if (hb_atomic_int32_get(&buffer->ref_cnt) == REF_CNT_INVALID_VAL) return; hb_atomic_int32_add(&buffer->ref_cnt, -1); if (hb_atomic_int32_get(&buffer->ref_cnt) > 0) return; hb_atomic_int32_set(&buffer->ref_cnt, REF_CNT_INVALID_VAL); hb_unicode_funcs_destroy(buffer->unicode); free(buffer->info); free(buffer->pos); free(buffer); }
void hb_font_destroy(hb_font_t *font) { if (!font) return; if (hb_atomic_int32_get(&font->ref_cnt) == REF_CNT_INVALID_VAL) return; hb_atomic_int32_add(&font->ref_cnt, -1); if (hb_atomic_int32_get(&font->ref_cnt) > 0) return; hb_atomic_int32_set(&font->ref_cnt, REF_CNT_INVALID_VAL); #ifdef HAVE_GRAPHITE2 if (font->shaper_data.graphite2 && font->shaper_data.graphite2 != HB_SHAPER_DATA_INVALID && font->shaper_data.graphite2 != HB_SHAPER_DATA_SUCCEEDED) hb_graphite2_shaper_font_data_destroy(font->shaper_data.graphite2); #endif #ifdef HAVE_OT if (font->shaper_data.ot && font->shaper_data.ot != HB_SHAPER_DATA_INVALID && font->shaper_data.ot != HB_SHAPER_DATA_SUCCEEDED) hb_ot_shaper_font_data_destroy(font->shaper_data.ot); #endif if (font->shaper_data.fallback && font->shaper_data.fallback != HB_SHAPER_DATA_INVALID && font->shaper_data.fallback != HB_SHAPER_DATA_SUCCEEDED) hb_fallback_shaper_font_data_destroy(font->shaper_data.fallback); if (font->destroy) font->destroy(font->user_data); hb_font_destroy(font->parent); hb_face_destroy(font->face); hb_font_funcs_destroy(font->klass); free(font); }