[repacker] Expose on internal method in the repacker that allows the caller to pass in/out a graph. Will be used in testing so we can compare graphs instead of packed result.
diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 5f23414..0d3dae2 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh
@@ -196,7 +196,8 @@ : parents_invalid (true), distance_invalid (true), positions_invalid (true), - successful (true) + successful (true), + buffers () { num_roots_for_space_.push (1); bool removed_nil = false; @@ -228,6 +229,8 @@ ~graph_t () { vertices_.fini (); + for (char* b : buffers) + hb_free (b); } bool in_error () const @@ -255,6 +258,11 @@ return vertices_[i].obj; } + void add_buffer (char* buffer) + { + buffers.push (buffer); + } + /* * Adds a 16 bit link from parent_id to child_id */ @@ -1127,6 +1135,7 @@ bool positions_invalid; bool successful; hb_vector_t<unsigned> num_roots_for_space_; + hb_vector_t<char*> buffers; }; }
diff --git a/src/graph/gsubgpos-context.cc b/src/graph/gsubgpos-context.cc index e0ff6ff..b204442 100644 --- a/src/graph/gsubgpos-context.cc +++ b/src/graph/gsubgpos-context.cc
@@ -33,8 +33,7 @@ : table_tag (table_tag_), graph (graph_), lookup_list_index (0), - lookups (), - buffers () + lookups () { if (table_tag_ != HB_OT_TAG_GPOS && table_tag_ != HB_OT_TAG_GSUB) @@ -53,7 +52,7 @@ if (!buffer) return -1; - buffers.push (buffer); + add_buffer (buffer); return graph.new_node (buffer, buffer + size); }
diff --git a/src/graph/gsubgpos-context.hh b/src/graph/gsubgpos-context.hh index 49b2419..9fe9662 100644 --- a/src/graph/gsubgpos-context.hh +++ b/src/graph/gsubgpos-context.hh
@@ -40,22 +40,16 @@ graph_t& graph; unsigned lookup_list_index; hb_hashmap_t<unsigned, graph::Lookup*> lookups; - hb_vector_t<char*> buffers; + HB_INTERNAL gsubgpos_graph_context_t (hb_tag_t table_tag_, graph_t& graph_); - ~gsubgpos_graph_context_t () - { - for (char* b : buffers) - hb_free (b); - } - HB_INTERNAL unsigned create_node (unsigned size); void add_buffer (char* buffer) { - buffers.push (buffer); + graph.add_buffer (buffer); } private: