Remove Offset::serialize()

Finishing https://github.com/harfbuzz/harfbuzz/pull/2355
This commit is contained in:
Behdad Esfahbod 2021-07-09 11:58:36 -06:00
parent 63e15eac4f
commit 29c9833e57
2 changed files with 13 additions and 16 deletions

View File

@ -133,18 +133,24 @@ typedef struct OpenTypeOffsetTable
/* Write OffsetTables, alloc for and write actual table blobs. */
for (unsigned int i = 0; i < tables.len; i++)
{
TableRecord &rec = tables.arrayZ[i];
hb_blob_t *blob = items[i].blob;
rec.tag = items[i].tag;
rec.length = blob->length;
rec.offset.serialize (c, this);
unsigned len = blob->length;
/* Allocate room for the table and copy it. */
char *start = (char *) c->allocate_size<void> (rec.length);
char *start = (char *) c->allocate_size<void> (len);
if (unlikely (!start)) return false;
if (likely (rec.length))
memcpy (start, blob->data, rec.length);
TableRecord &rec = tables.arrayZ[i];
rec.tag = items[i].tag;
rec.length = len;
rec.offset = 0;
if (unlikely (!c->check_assign (rec.offset,
(unsigned) ((char *) start - (char *) this),
HB_SERIALIZE_ERROR_OFFSET_OVERFLOW)))
return_trace (false);
if (likely (len))
memcpy (start, blob->data, len);
/* 4-byte alignment. */
c->align (4);

View File

@ -212,15 +212,6 @@ struct Offset : Type
bool is_null () const { return has_null && 0 == *this; }
void *serialize (hb_serialize_context_t *c, const void *base)
{
void *t = c->start_embed<void> ();
c->check_assign (*this,
(unsigned) ((char *) t - (char *) base),
HB_SERIALIZE_ERROR_OFFSET_OVERFLOW);
return t;
}
public:
DEFINE_SIZE_STATIC (sizeof (Type));
};