From 6a7ac79e26e85f6781186cf708a12825c0857324 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 May 2011 14:19:18 -0400 Subject: [PATCH] Plug leaks --- src/hb-ot-map-private.hh | 7 +++++++ src/hb-ot-shape-private.hh | 2 ++ src/hb-ot-shape.cc | 2 ++ src/hb-private.hh | 10 +++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh index 2a74138f3..02f5a9112 100644 --- a/src/hb-ot-map-private.hh +++ b/src/hb-ot-map-private.hh @@ -120,6 +120,13 @@ struct hb_ot_map_t { hb_ot_layout_position_lookup (font, buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask); } + inline void finish (void) { + feature_infos.finish (); + feature_maps.finish (); + lookup_maps[0].finish (); + lookup_maps[1].finish (); + } + private: hb_mask_t global_mask; diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index c0faf8ca6..b95815a98 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -51,6 +51,8 @@ struct hb_ot_shape_plan_t { hb_ot_map_t map; hb_ot_complex_shaper_t shaper; + + inline void finish (void) { map.finish (); } }; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4f90027ce..aa5b9206a 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -381,6 +381,8 @@ hb_ot_shape (hb_font_t *font, hb_ot_shape_plan_internal (&plan, font->face, &buffer->props, features, num_features); hb_ot_shape_execute (&plan, font, buffer, features, num_features); + + plan.finish (); } diff --git a/src/hb-private.hh b/src/hb-private.hh index f22e0d2ad..215ef9607 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -313,6 +313,14 @@ struct hb_prealloced_array_t { { return (const Type *) ::bsearch (key, array, len, sizeof (Type), (hb_compare_func_t) Type::cmp); } + + inline void finish (void) + { + if (array != static_array) + free (array); + array = NULL; + allocated = len = 0; + } }; template @@ -394,7 +402,7 @@ struct hb_lockable_set_t old.finish (); l.lock (); } - items.shrink (0); + items.finish (); l.unlock (); }