Plug leaks
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 11 May 2011 18:19:18 +0000 (14:19 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 11 May 2011 18:19:18 +0000 (14:19 -0400)
src/hb-ot-map-private.hh
src/hb-ot-shape-private.hh
src/hb-ot-shape.cc
src/hb-private.hh

index 2a74138..02f5a91 100644 (file)
@@ -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;
index c0faf8c..b95815a 100644 (file)
@@ -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 (); }
 };
 
 
index 4f90027..aa5b920 100644 (file)
@@ -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 ();
 }
 
 
index f22e0d2..215ef96 100644 (file)
@@ -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 <typename Type>
@@ -394,7 +402,7 @@ struct hb_lockable_set_t
        old.finish ();
        l.lock ();
     }
-    items.shrink (0);
+    items.finish ();
     l.unlock ();
   }