[subset] When serializing a DeviceRecord in hdmx pad to make 32 bit aligned.

This commit is contained in:
Garret Rieger 2018-02-21 15:36:09 -08:00
parent ab7a8f3b74
commit dddf44279f

View File

@ -53,6 +53,15 @@ struct DeviceRecord
return this->subset_plan->gids_to_retain_sorted.len;
}
inline unsigned int get_size () const
{
unsigned int raw_size = min_size + len () * HBUINT8::static_size;
if (raw_size % 4)
/* Align to 32 bits */
return raw_size + (4 - (raw_size % 4));
return raw_size;
}
inline const HBUINT8& operator [] (unsigned int i) const
{
if (unlikely (i >= len())) return Null(HBUINT8);
@ -65,16 +74,14 @@ struct DeviceRecord
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min ((*this)))) return_trace (false);
if (unlikely (!c->allocate_size<DeviceRecord> (subset_view.get_size())))
return_trace (false);
this->pixel_size.set (subset_view.source_device_record->pixel_size);
this->max_width.set (subset_view.source_device_record->max_width);
for (unsigned int i = 0; i < subset_view.len(); i++)
{
HBUINT8 *width = c->extend (this->widths[i]);
if (unlikely (!width)) return_trace (false);
width->set (subset_view[i]);
}
widths[i].set (subset_view[i]);
return_trace (true);
}