Imported Upstream version 1.8.1
[platform/upstream/harfbuzz.git] / src / hb-ot-map.cc
index 54b0ce3..46bf2db 100644 (file)
@@ -43,6 +43,10 @@ hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_,
 {
   memset (this, 0, sizeof (*this));
 
+  feature_infos.init ();
+  for (unsigned int table_index = 0; table_index < 2; table_index++)
+    stages[table_index].init ();
+
   face = face_;
   props = *props_;
 
@@ -63,11 +67,17 @@ hb_ot_map_builder_t::hb_ot_map_builder_t (hb_face_t *face_,
   }
 }
 
+hb_ot_map_builder_t::~hb_ot_map_builder_t (void)
+{
+  feature_infos.fini ();
+  for (unsigned int table_index = 0; table_index < 2; table_index++)
+    stages[table_index].fini ();
+}
+
 void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value,
                                       hb_ot_map_feature_flags_t flags)
 {
   feature_info_t *info = feature_infos.push();
-  if (unlikely (!info)) return;
   if (unlikely (!tag)) return;
   info->tag = tag;
   info->seq = feature_infos.len;
@@ -108,8 +118,6 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t  &m,
       if (lookup_indices[i] >= table_lookup_count)
        continue;
       hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push ();
-      if (unlikely (!lookup))
-        return;
       lookup->mask = mask;
       lookup->index = lookup_indices[i];
       lookup->auto_zwnj = auto_zwnj;
@@ -124,10 +132,8 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t  &m,
 void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
 {
   stage_info_t *s = stages[table_index].push ();
-  if (likely (s)) {
-    s->index = current_stage[table_index];
-    s->pause_func = pause_func;
-  }
+  s->index = current_stage[table_index];
+  s->pause_func = pause_func;
 
   current_stage[table_index]++;
 }
@@ -164,9 +170,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t  &m,
                                                &required_feature_tag[table_index]);
   }
 
-  if (!feature_infos.len)
-    return;
-
   /* Sort features and merge duplicates */
   {
     feature_infos.qsort ();
@@ -241,8 +244,6 @@ hb_ot_map_builder_t::compile (hb_ot_map_t  &m,
 
 
     hb_ot_map_t::feature_map_t *map = m.features.push ();
-    if (unlikely (!map))
-      break;
 
     map->tag = info->tag;
     map->index[0] = feature_index[0];
@@ -324,10 +325,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t  &m,
 
       if (stage_index < stages[table_index].len && stages[table_index][stage_index].index == stage) {
        hb_ot_map_t::stage_map_t *stage_map = m.stages[table_index].push ();
-       if (likely (stage_map)) {
-         stage_map->last_lookup = last_num_lookups;
-         stage_map->pause_func = stages[table_index][stage_index].pause_func;
-       }
+       stage_map->last_lookup = last_num_lookups;
+       stage_map->pause_func = stages[table_index][stage_index].pause_func;
 
        stage_index++;
       }