diff options
author | Raph Levien <raph@google.com> | 2014-05-19 13:21:21 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2014-05-19 14:01:37 -0700 |
commit | c31e3883456e018d742e9f29815ba5ff8b315ea1 (patch) | |
tree | ca0e5d7f03ad7a06496c89c432220d5f08c0d80e /libs/minikin/Layout.cpp | |
parent | a3998d4f51e862f00b3dc6b8b99cfbeea2622b2d (diff) | |
download | android_frameworks_minikin-c31e3883456e018d742e9f29815ba5ff8b315ea1.tar.gz android_frameworks_minikin-c31e3883456e018d742e9f29815ba5ff8b315ea1.tar.bz2 android_frameworks_minikin-c31e3883456e018d742e9f29815ba5ff8b315ea1.zip |
Fix incomplete refcounting and locking
These changes were supposed to be committed in the previous patch
"Better refcounting and locking" but seem to have gotten lost in a
rebase. It fixes a memory leak and some possible race conditions.
Change-Id: I54ca1e37500ec49756fe317cc6d6d03da9911501
Diffstat (limited to 'libs/minikin/Layout.cpp')
-rw-r--r-- | libs/minikin/Layout.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp index 3a0be6a..f32e9f4 100644 --- a/libs/minikin/Layout.cpp +++ b/libs/minikin/Layout.cpp @@ -161,6 +161,7 @@ hb_font_funcs_t* getHbFontFuncs() { hb_font_t* create_hb_font(MinikinFont* minikinFont, MinikinPaint* minikinPaint) { hb_face_t* face = hb_face_create_for_tables(referenceTable, minikinFont, NULL); hb_font_t* font = hb_font_create(face); + hb_face_destroy(face); hb_font_set_funcs(font, getHbFontFuncs(), minikinPaint, 0); // TODO: manage ownership of face return font; @@ -176,6 +177,12 @@ static hb_position_t HBFloatToFixed(float v) return scalbnf (v, +8); } +Layout::~Layout() { + for (size_t ix = 0; ix < mHbFonts.size(); ix++) { + hb_font_destroy(mHbFonts[ix]); + } +} + void Layout::dump() const { for (size_t i = 0; i < mGlyphs.size(); i++) { const LayoutGlyph& glyph = mGlyphs[i]; |