From 2e7f1ae48feaa2db8248b7ae01e46ef70e461a31 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 May 2022 12:49:16 -0600 Subject: [PATCH] [subset] Use vector.allocated size instead of tracking buf_size --- src/hb-subset.cc | 10 +++++----- src/hb-vector.hh | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index cc695111d..0cda2f498 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -123,7 +123,6 @@ static bool _try_subset (const TableType *table, hb_vector_t* buf, - unsigned buf_size, hb_subset_context_t* c /* OUT */) { c->serializer->start_serialize (); @@ -136,6 +135,7 @@ _try_subset (const TableType *table, return needed; } + unsigned buf_size = buf->allocated; buf_size = buf_size * 2 + 16; DEBUG_MSG (SUBSET, nullptr, "OT::%c%c%c%c ran out of room; reallocating to %u bytes.", HB_UNTAG (c->table_tag), buf_size); @@ -147,8 +147,8 @@ _try_subset (const TableType *table, return needed; } - c->serializer->reset (buf->arrayZ, buf_size); - return _try_subset (table, buf, buf_size, c); + c->serializer->reset (buf->arrayZ, buf->allocated); + return _try_subset (table, buf, c); } template @@ -180,10 +180,10 @@ _subset (hb_subset_plan_t *plan, hb_vector_t &buf) } bool needed = false; - hb_serialize_context_t serializer (buf.arrayZ, buf_size); + hb_serialize_context_t serializer (buf.arrayZ, buf.allocated); { hb_subset_context_t c (source_blob, plan, &serializer, tag); - needed = _try_subset (table, &buf, buf_size, &c); + needed = _try_subset (table, &buf, &c); } hb_blob_destroy (source_blob); diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 6c7d32e49..eefae3834 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -70,9 +70,8 @@ struct hb_vector_t : std::conditional, hb_empty } ~hb_vector_t () { fini (); } - private: - int allocated = 0; /* == -1 means allocation failed. */ public: + int allocated = 0; /* == -1 means allocation failed. */ unsigned int length = 0; public: Type *arrayZ = nullptr;